About 900 years ago, a Chinese philosopher Sima Guang wrote a history book in which he talked about people's talent and virtue. According to his theory, a man being outstanding in both talent and virtue must be a "sage(圣人)"; being less excellent but with one's virtue outweighs talent can be called a "nobleman(君子)"; being good in neither is a "fool man(愚人)"; yet a fool man is better than a "small man(小人)" who prefers talent than virtue.

Now given the grades of talent and virtue of a group of people, you are supposed to rank them according to Sima Guang's theory.

Input Specification:

Each input file contains one test case. Each case first gives 3 positive integers in a line: N (≤), the total number of people to be ranked; L (≥), the lower bound of the qualified grades -- that is, only the ones whose grades of talent and virtue are both not below this line will be ranked; and H (<), the higher line of qualification -- that is, those with both grades not below this line are considered as the "sages", and will be ranked in non-increasing order according to their total grades. Those with talent grades below H but virtue grades not are cosidered as the "noblemen", and are also ranked in non-increasing order according to their total grades, but they are listed after the "sages". Those with both grades below H, but with virtue not lower than talent are considered as the "fool men". They are ranked in the same way but after the "noblemen". The rest of people whose grades both pass the L line are ranked after the "fool men".

Then N lines follow, each gives the information of a person in the format:

ID_Number Virtue_Grade Talent_Grade

where ID_Number is an 8-digit number, and both grades are integers in [0, 100]. All the numbers are separated by a space.

Output Specification:

The first line of output must give M (≤), the total number of people that are actually ranked. Then M lines follow, each gives the information of a person in the same format as the input, according to the ranking rules. If there is a tie of the total grade, they must be ranked with respect to their virtue grades in non-increasing order. If there is still a tie, then output in increasing order of their ID's.

Sample Input:

14 60 80
10000001 64 90
10000002 90 60
10000011 85 80
10000003 85 80
10000004 80 85
10000005 82 77
10000006 83 76
10000007 90 78
10000008 75 79
10000009 59 90
10000010 88 45
10000012 80 100
10000013 90 99
10000014 66 60

Sample Output:

12
10000013 90 99
10000012 80 100
10000003 85 80
10000011 85 80
10000004 80 85
10000007 90 78
10000006 83 76
10000005 82 77
10000002 90 60
10000014 66 60
10000008 75 79
10000001 64 90
题目分析:想直接在一个vector处理 但是导致compare函数写的不对 在读入数据时 就将属于不同类别的先归类 再进行排序
 #define _CRT_SECURE_NO_WARNINGS
#include <climits>
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
struct Person {
int Id;
int Vir_Grade;
int Tal_Grade;
};
int N, L, H;
vector<Person> P[];
bool compare(const Person& a, const Person& b)
{
int Grade_a = a.Tal_Grade + a.Vir_Grade;
int Grade_b = b.Tal_Grade + b.Vir_Grade;
if (Grade_a != Grade_b)
return Grade_a > Grade_b;
else if (a.Vir_Grade != b.Vir_Grade)
return a.Vir_Grade > b.Vir_Grade;
else return a.Id < b.Id;
}
int main()
{ scanf("%d %d %d", &N,&L,&H);
for(int i=;i<N;i++)
{
int id;
int V_Grade, T_Grade;
scanf("%d %d %d", &id, &V_Grade, &T_Grade);
if (V_Grade < L || T_Grade < L)continue;
if (V_Grade >= H && T_Grade >= H)
P[].push_back({ id,V_Grade,T_Grade });
else if (V_Grade>=H && T_Grade < H)
P[].push_back({ id,V_Grade,T_Grade });
else if(V_Grade<H&&T_Grade<H&&V_Grade>=T_Grade)
P[].push_back({ id,V_Grade,T_Grade });
else
P[].push_back({ id,V_Grade,T_Grade });
}
int size = ;
for (int i = ; i <; i++)
{
size += P[i].size();
sort(P[i].begin(), P[i].end(), compare);
}
cout << size << endl;
for (int i = ; i < ; i++)
for (auto it : P[i])
cout << it.Id << " " << it.Vir_Grade << " " << it.Tal_Grade << endl;
return ;
}

1062 Talent and Virtue (25分)(水)的更多相关文章

  1. PAT 甲级 1062 Talent and Virtue (25 分)(简单,结构体排序)

    1062 Talent and Virtue (25 分)   About 900 years ago, a Chinese philosopher Sima Guang wrote a histor ...

  2. PAT甲题题解-1062. Talent and Virtue (25)-排序水题

    水题,分组排序即可. #include <iostream> #include <cstdio> #include <algorithm> #include < ...

  3. 【PAT甲级】1062 Talent and Virtue (25 分)

    题意: 输入三个正整数N,L,H(N<=1E5,L>=60,H<100,H>L),分别代表人数,及格线和高水平线.接着输入N行数据,每行包括一个人的ID,道德数值和才能数值.一 ...

  4. 1062. Talent and Virtue (25)【排序】——PAT (Advanced Level) Practise

    题目信息 1062. Talent and Virtue (25) 时间限制200 ms 内存限制65536 kB 代码长度限制16000 B About 900 years ago, a Chine ...

  5. 1062 Talent and Virtue (25)

    /* L (>=60), the lower bound of the qualified grades -- that is, only the ones whose grades of ta ...

  6. pat 1062. Talent and Virtue (25)

    难得的一次ac 题目意思直接,方法就是对virtue talent得分进行判断其归属类型,用0 1 2 3 4 表示 不合格 sage noblemen foolmen foolmen 再对序列进行排 ...

  7. PAT (Advanced Level) 1062. Talent and Virtue (25)

    简单排序.题意较长. #include<cstdio> #include<cstring> #include<cmath> #include<queue> ...

  8. pat1062. Talent and Virtue (25)

    1062. Talent and Virtue (25) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Li Abou ...

  9. 1062 Talent and Virtue (25 分)

    1062 Talent and Virtue (25 分) About 900 years ago, a Chinese philosopher Sima Guang wrote a history ...

随机推荐

  1. vue中v-if和v-show的区别

    v-if.v-show顾名思义就是用来判断视图层展示效果的.  v-if 指令用于条件性地渲染一块内容.这块内容只会在指令的表达式返回真值的时候被渲染. v-show 指的是单纯的切换元素的样式dis ...

  2. Effective Go中文版(更新中)

    原文链接:https://golang.org/doc/effective_go.html Introduction Go是一种新兴的编程语言.虽然它借鉴了现有语言的思想,但它具有不同寻常的特性,使得 ...

  3. 查看chrome插件源码

    简介 想查看chrome插件的源码,就需要找到chrome插件安装的位置,接着再文件夹下查找此插件的id. mac cd ~/Library/Application Support/Google/Ch ...

  4. pyppeteer使用时常见的bug及基本使用(转)

    pyppeteer使用时常见的bug及解决办法: https://blog.csdn.net/Mr__lqy/article/details/102626025 pyppeteer的基本使用: htt ...

  5. php 数据库 操作

    header.php <?php error_reporting(0);//加上error_reporting(0);就不会弹出警告了 // header("Content-type: ...

  6. Python基础篇_实例练习(二)

    问题1:假设有同学A,A每周在工作日进步,周末退步,问一年(365天)后A同学是一年前的几倍? 工作日进步由用户输入,周末下降0.01即1% deyup = eval(input()) deyfact ...

  7. tars之springboot的初步使用

    公司要求使用tars框架,现学习的,听老大讲的经验和看的一些技术博客,感觉和SpringCloud有些相似,不过内部有自己的规范,基于rpc实现的服务与服务之间的远程调用,而cloud的远程调用是基于 ...

  8. nmon使用问题汇总(不定期更新)

    nmon使用问题汇总 1.nmon常用命令: ./nmon -s1 -c300 -f -m /root/nmon-test-result/项目-50并发/ 2.设置nmon参数为-s1 -c720,发 ...

  9. SpringCloud学习系列<一>版本介绍

    SpringCloud学习踩坑记<一> SpringCloud版本迭代实在太快,学习起来也是各种坑,博主用的是"当前"的最新版本,借鉴周立老大的Spring Cloud ...

  10. CSS劫持攻击

    CSS劫持攻击 CSS劫持是一种并不很受重视的劫持方式,但是其也有一定的危害,且由于其并不一定需要依赖JavaScript,这使得此种攻击方式更容易实现. ClickJacking点击劫持 当访问某网 ...