1062. Talent and Virtue (25)

时间限制
200 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Li

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 (<=105), the total number of people to be ranked; L (>=60), 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 (<100), 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 (<=N), 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

提交代码

文字游戏,幸好题目的样例很典型。

 #include<cstdio>
#include<stack>
#include<cstring>
#include<iostream>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
struct record{
char id[];
int VG,TG,r;
record(){
r=;
}
};
bool cmp(record a,record b){
if(a.r==b.r){
if(a.VG+a.TG==b.VG+b.TG){
if(a.VG==b.VG){
return strcmp(a.id,b.id)<;
}
return a.VG>b.VG;
}
return a.VG+a.TG>b.VG+b.TG;
}
return a.r>b.r;
}
//Virtue_Grade Talent_Grade
int main(){
//freopen("D:\\INPUT.txt","r",stdin);
int n,l,h;
scanf("%d %d %d",&n,&l,&h);
record *per=new record[n+];
int i,count=,VG,TG,r=;
char id[];
for(i=;i<n;i++){
scanf("%s %d %d",&id,&VG,&TG);
if(VG>=l&&TG>=l){//有可能
if(VG>=h&&TG>=h){
per[count].r+=;
}
else if(VG>=h&&TG<h){//nobleman
per[count].r+=;
}
else if(VG<h&&TG<h&&VG>=TG){//fool man
per[count].r+=;
}
strcpy(per[count].id,id);
per[count].VG=VG;
per[count].TG=TG;
count++;
}
}
sort(per,per+count,cmp);
printf("%d\n",count);
for(i=;i<count;i++){
printf("%s %d %d\n",per[i].id,per[i].VG,per[i].TG);
}
return ;
}

pat1062. Talent and Virtue (25)的更多相关文章

  1. 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 ...

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

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

  3. 1062 Talent and Virtue (25)

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

  4. 1062 Talent and Virtue (25分)(水)

    About 900 years ago, a Chinese philosopher Sima Guang wrote a history book in which he talked about ...

  5. pat 1062. Talent and Virtue (25)

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

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

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

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

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

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

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

  9. PAT_A1062#Talent and Virtue

    Source: PAT A1062 Talent and Virtue (25 分) Description: About 900 years ago, a Chinese philosopher S ...

随机推荐

  1. css3 利用perspective实现翻页效果和正方体 以及翻转效果

    要点: 1 实现3D效果就需要使用perspective属性 1 页面旋转使用css3的rorate 2 使用backface-visibility 实现正面元素翻转之后背面不可见,显示出反面的元素 ...

  2. RESTEasy入门学习

    RESTEasy是JBoss的开源项目之一,是一个RESTful Web Services框架.RESTEasy的开发者Bill Burke同时也是JAX-RS的J2EE标准制定者之一.JAX-RS是 ...

  3. java基础知识(3)----面向对象

    三:面向对象:特点: 1:将复杂的事情简单化.2:面向对象将以前的过程中的执行者,变成了指挥者.3:面向对象这种思想是符合现在人们思考习惯的一种思想. 过程和对象在我们的程序中是如何体现的呢?过程其实 ...

  4. windows统计端口连接数

    netstat -na -p tcp| findstr 80 | find /C "ESTABLISH" netstat -an -p tcp | find "127.0 ...

  5. Tiny4412学习杂记

    1.Android 挂载NFS 使用 busybox mount 来替代mount命令 2.修改Uboot中fastboot最大buff  使用U-boot烧写Android5.0的时候出现 remo ...

  6. 各种浏览器下的user-agent

    ie11Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko safariMozilla/5.0 (Macintos ...

  7. com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; che

    出现此种错误,我暂时遇到了两次. 1 我的字段的名称和数据库的关键字重合. 上图中的desc是默认降序排列的意思. 2 第二次出现的异常是我在重构代码阶段遇到的一个bug.不过我暂时不能理解,虽然解决 ...

  8. hadoop作业调优参数整理及原理

    hadoop作业调优参数整理及原理 10/22. 2013 1 Map side tuning参数 1.1 MapTask运行内部原理 当map task开始运算,并产生中间数据时,其产生的中间结果并 ...

  9. 《精通Spring4.X企业应用开发实战》读后感第六章(引用Bean的属性值)

  10. datatables的使用

    在开发web项目中,界面就是一个以丰富友好的样式来展现数据的窗口,同样的数据不用的展现形式给人不同的体验,数据列表是数据是一种常见展现形式,对于数据列表的一个最基本的要求就是能够实现分页以及检索功能. ...