1062 Talent and Virtue (25 分)
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
分析:水题,sort排序即可
/**
* Copyright(c)
* All rights reserved.
* Author : Mered1th
* Date : 2019-02-25-01.10.26
* Description : A1062
*/
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<unordered_set>
#include<map>
#include<vector>
#include<set>
using namespace std;
int n,l,h;
struct Node{
int id,vg,tg;
int total;
int flag;
}node[];
bool cmp(Node a,Node b){
if(a.flag!=b.flag) return a.flag<b.flag;
else if(a.total!=b.total) return a.total>b.total;
else if(a.vg!=b.vg) return a.vg>b.vg;
else return a.id<b.id;
}
int main(){
#ifdef ONLINE_JUDGE
#else
freopen("1.txt", "r", stdin);
#endif
cin>>n>>l>>h;
int id,vg,tg,num=n;
;i<n;i++){
scanf("%d%d%d",&id,&vg,&tg);
node[i].id=id;
node[i].vg=vg;
node[i].tg=tg;
node[i].total=vg+tg;
if(vg<l || tg<l){
node[i].flag=;
num--;
}
else if(vg>=h &&tg>=h){
node[i].flag=;
}
else if(vg>=h &&tg<h){
node[i].flag=;
}
else if(vg<h && tg<h && vg>=tg){
node[i].flag=;
}
else{
node[i].flag=;
}
}
sort(node,node+n,cmp);
printf("%d\n",num);
;i<num;i++){
cout<<node[i].id<<" "<<node[i].vg<<" "<<node[i].tg<<endl;
}
;
}
1062 Talent and Virtue (25 分)的更多相关文章
- PAT 甲级 1062 Talent and Virtue (25 分)(简单,结构体排序)
1062 Talent and Virtue (25 分) About 900 years ago, a Chinese philosopher Sima Guang wrote a histor ...
- 1062 Talent and Virtue (25分)(水)
About 900 years ago, a Chinese philosopher Sima Guang wrote a history book in which he talked about ...
- 【PAT甲级】1062 Talent and Virtue (25 分)
题意: 输入三个正整数N,L,H(N<=1E5,L>=60,H<100,H>L),分别代表人数,及格线和高水平线.接着输入N行数据,每行包括一个人的ID,道德数值和才能数值.一 ...
- 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 ...
- 1062 Talent and Virtue (25)
/* L (>=60), the lower bound of the qualified grades -- that is, only the ones whose grades of ta ...
- pat 1062. Talent and Virtue (25)
难得的一次ac 题目意思直接,方法就是对virtue talent得分进行判断其归属类型,用0 1 2 3 4 表示 不合格 sage noblemen foolmen foolmen 再对序列进行排 ...
- PAT (Advanced Level) 1062. Talent and Virtue (25)
简单排序.题意较长. #include<cstdio> #include<cstring> #include<cmath> #include<queue> ...
- PAT甲题题解-1062. Talent and Virtue (25)-排序水题
水题,分组排序即可. #include <iostream> #include <cstdio> #include <algorithm> #include < ...
- pat1062. Talent and Virtue (25)
1062. Talent and Virtue (25) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Li Abou ...
随机推荐
- SharePoint BDC(Business Data Connectivity)服务-PowerShell
1. 获取BCS服务应用程序的标识 Get-SPServiceApplication 2. 获取指定的BCS服务应用程序实例 $bcs = Get-SPServiceApplication -Iden ...
- 关于DIY操作系统的断更道歉
去年9月份正是开学的时候,刚开学没感觉忙.但是随着课程的深入,而且都是专业课,再加上招娉会一个接一个的来,渐渐显得力不从心.由于我对操作系统这一方面也是一知半解,以前也没有系统地学过计算机方面的东西, ...
- 配置thunderbirdmail
添加帐号 打开Edit→Account Settings ,选择左下放的 "Account actions"→"Add Mail Account". 在弹出框中 ...
- myeclipse 与 webstrom 免解析node_modules 的方法
myeclipse : 1.项目文件夹上:右键 properites - > 搜索 filter -->resouce filters 2. webStrom : File - ...
- [Python] 网络编程之TCP编程
转自:TCP编程 - 廖雪峰的官方网站 Socket是网络编程的一个抽象概念.通常我们用一个Socket表示“打开了一个网络链接”,而打开一个Socket需要知道目标计算机的IP地址和端口号,再指定协 ...
- lintcode 刷题 by python 总结(1)
博主之前在学习 python 的数据结构与算法的基础知识,用的是<problem-solving-with-algorithms-and-data-structure-using-python& ...
- Jordan标准形
一.引入 前面已经指出,一切n阶矩阵A可以分成许多相似类.今要在与A相似的全体矩阵中,找出一个较简单的矩阵来作为相似类的标准形.当然以对角矩阵作为标准形最好,可惜不是每一个矩阵都能与对角矩阵相似.因此 ...
- StyleCop 是什么,可以帮助团队带来什么价值?
StyleCop 本质上是一个 C# 源代码规则分析器,可以帮助团队成员强制执行一组代码样式和一致性规则. 本文将简述 StyleCop 以及它能为团队带来的价值. 本文内容 StyleCop 是什么 ...
- jsp页面九大内置对象
资源转载自网上,不可用于商用,学习可以.内置对象又叫隐式对象/隐含对象是由WEB容器加载的一组类的实例,不需要预先声明就可以在脚本代码和表达式中随意使用的对象. 这九大隐式对象可以按照期作用分类为: ...
- CH3602 Counting Swaps
题意 3602 Counting Swaps 0x30「数学知识」例题 背景 https://ipsc.ksp.sk/2016/real/problems/c.html Just like yeste ...