博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
1062 Talent and Virtue (25)
阅读量:4698 次
发布时间:2019-06-09

本文共 4090 字,大约阅读时间需要 13 分钟。

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 (<=10^5^), 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 8010000001 64 9010000002 90 6010000011 85 8010000003 85 8010000004 80 8510000005 82 7710000006 83 7610000007 90 7810000008 75 7910000009 59 9010000010 88 4510000012 80 10010000013 90 9910000014 66 60

Sample Output:

1210000013 90 9910000012 80 10010000003 85 8010000011 85 8010000004 80 8510000007 90 7810000006 83 7610000005 82 7710000002 90 6010000014 66 6010000008 75 7910000001 64 90
 
题目大意:给出一些人的virtue和talent分数,以及及格分和优秀分, 两者均高于及格的才能被排名, 两者均高于优秀分的被称作sage,virute不低于优秀分,talent低于优秀分称作nobleman,两者均低于优秀分,且virtue高于talent则称作foolman,其他的称作small man,按照总分对这四类人排序,且sage,nobleman, foolman,smallman的优先级依次降低。 总分相同的情况下按照virtue排序, 依然相同的情况下按照名字排序
思路:构建一个struct node记录考生的virute,talent, id, total 和priority(优先级); 在输入数据的时候,确定学生的优先级和总分,把每符合要求的学生添加vector<node> v中, 对v进行排序后输出;
注意点:foolman的评定标准是virtue,talent分数低于优秀分,并且virtue>=talent,而不是virtue>talent, 注意排序的规则, 是不低于 还是低于, 此外 在输入的时候就可以筛选不合格数的数据
 
1 #include
2 #include
3 #include
4 using namespace std; 5 struct Node{ 6 int talnet, virtue, total, priority; 7 int id; 8 }; 9 10 bool cmp(Node& a, Node& b){11 if(a.priority!=b.priority) return a.priority
b.total;13 if(a.virtue!=b.virtue) return a.virtue>b.virtue;14 return a.id
v(n+1);20 int idx=0;21 for(i=0; i
=high && talnet>=high) priority=1;26 else if(virtue>=high && talnet>=low) priority=2;27 else if(virtue>=talnet && talnet>=low) priority = 3;28 else if(virtue>=low && talnet>=low) priority = 4;29 //优先级为-1表示至少有一个分数小于low30 if(priority!=-1){31 v[idx].id = id;32 v[idx].talnet = talnet;33 v[idx].virtue = virtue;34 v[idx].priority = priority;35 v[idx].total = virtue + talnet;36 idx++;37 }38 }39 sort(v.begin(), v.begin()+idx, cmp);40 printf("%d\n", idx);41 for(i=0; i

 

 

转载于:https://www.cnblogs.com/mr-stn/p/9174355.html

你可能感兴趣的文章
gulpfile 压缩模板
查看>>
【34.14%】【BZOJ 3110】 [Zjoi2013]K大数查询
查看>>
【 henuacm2016级暑期训练-动态规划专题 A 】Cards
查看>>
第五篇:白话tornado源码之褪去模板的外衣
查看>>
设备常用框架framework
查看>>
bootstrap模态框和select2合用时input无法获取焦点(转)
查看>>
MockObject
查看>>
Chukwa
查看>>
(转)Maven仓库——私服介绍
查看>>
设计模式之工厂模式
查看>>
仿复制粘贴功能,长按弹出tips的实现
查看>>
Kubernetes-Host网络模式应用
查看>>
第三次作业
查看>>
sqlplus terminators - Semicolumn (;), slash (/) and a blank line
查看>>
省选知识清单/计划列表(咕?)
查看>>
远程桌面(3389)复制(拖动)文件
查看>>
转 lucene3搜索引擎,索引建立搜索排序分页高亮显示, IKAnalyzer分词
查看>>
win10应用UserControl
查看>>
BZOJ4516: [Sdoi2016]生成魔咒(后缀自动机)
查看>>
查看手机已经记住的WIFI密码
查看>>