题意:

输入三个正整数N,L,H(N<=1E5,L>=60,H<100,H>L),分别代表人数,及格线和高水平线。接着输入N行数据,每行包括一个人的ID,道德数值和才能数值。一个人的道德和才能都不低于H时为圣人,道德不低于H才能不低于L时为贵族,道德和才能都不低于L且道德不低于才能时为愚者,道德和才能都不低于L且道德低于才能时为小人(圣人优先判断,圣人的才能可以高于道德)。分别在自己的所在的群体内排序,依照道德才能总和降序排序,第二优先为才能的数值降序,第三优先为id的升序。按照题意输出排序的总人数以及输出它们的信息。

AAAAAccepted code:

 #define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
typedef struct student{
string id;
int v,t;
int sum;
};
student sage[],noble[],fool[],small[];
bool cmp(student a,student b){
if(a.sum!=b.sum)
return a.sum>b.sum;
if(a.v!=b.v)
return a.v>b.v;
return a.id<b.id;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,l,h;
cin>>n>>l>>h;
int cnt1=,cnt2=,cnt3=,cnt4=;
for(int i=;i<=n;++i){
string id;
cin>>id;
int v,t;
cin>>v>>t;
if(v>=h&&t>=h){
sage[++cnt1].id=id;
sage[cnt1].v=v;
sage[cnt1].t=t;
sage[cnt1].sum=v+t;
}
else if(v>=h&&t>=l){
noble[++cnt2].id=id;
noble[cnt2].v=v;
noble[cnt2].t=t;
noble[cnt2].sum=v+t;
}
else if(v>=l&&t>=l&&v>=t){
fool[++cnt3].id=id;
fool[cnt3].v=v;
fool[cnt3].t=t;
fool[cnt3].sum=v+t;
}
else if(v>=l&&t>=l&&v<t){
small[++cnt4].id=id;
small[cnt4].v=v;
small[cnt4].t=t;
small[cnt4].sum=v+t;
}
}
sort(sage+,sage++cnt1,cmp);
sort(noble+,noble++cnt2,cmp);
sort(fool+,fool++cnt3,cmp);
sort(small+,small++cnt4,cmp);
cout<<cnt1+cnt2+cnt3+cnt4<<"\n";
for(int i=;i<=cnt1;++i)
cout<<sage[i].id<<" "<<sage[i].v<<" "<<sage[i].t<<"\n";
for(int i=;i<=cnt2;++i)
cout<<noble[i].id<<" "<<noble[i].v<<" "<<noble[i].t<<"\n";
for(int i=;i<=cnt3;++i)
cout<<fool[i].id<<" "<<fool[i].v<<" "<<fool[i].t<<"\n";
for(int i=;i<=cnt4;++i)
cout<<small[i].id<<" "<<small[i].v<<" "<<small[i].t<<"\n";
return ;
}

【PAT甲级】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. 1062 Talent and Virtue (25分)(水)

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

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

  4. PAT 甲级 1040 Longest Symmetric String (25 分)(字符串最长对称字串,遍历)

    1040 Longest Symmetric String (25 分)   Given a string, you are supposed to output the length of the ...

  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 甲级 1083 List Grades (25 分)

    1083 List Grades (25 分) Given a list of N student records with name, ID and grade. You are supposed ...

  7. PAT甲级——1130 Infix Expression (25 分)

    1130 Infix Expression (25 分)(找规律.中序遍历) 我是先在CSDN上面发表的这篇文章https://blog.csdn.net/weixin_44385565/articl ...

  8. PAT 甲级 1074 Reversing Linked List (25 分)(链表部分逆置,结合使用双端队列和栈,其实使用vector更简单呐)

    1074 Reversing Linked List (25 分)   Given a constant K and a singly linked list L, you are supposed ...

  9. PAT 甲级 1086 Tree Traversals Again (25分)(先序中序链表建树,求后序)***重点复习

    1086 Tree Traversals Again (25分)   An inorder binary tree traversal can be implemented in a non-recu ...

随机推荐

  1. Python记:通用的序列操作之成员资格(听起来倒是有些抽象的!)

    ______________________________永远守护这一尘不染的真心! 要检查特定的值是否包含在序列中,可使用运算符in.它检查是否满足指定的条件,并返回相应的值:满足时返回True, ...

  2. library 中的internal power为何为负值?

    下图是library中一个寄存器Q pin 的internal_power table, 表中该pin 的internal power 大多都是负值.其实library 中的internal_powe ...

  3. codeforces 1204C Anna, Svyatoslav and Maps(floyd+dp)

    题目链接:http://codeforces.com/problemset/problem/1204/C 给定一组序列,P1,P2,P3...Pm,这是一组合法路径的序列,即任意的Pi和Pi+1之间有 ...

  4. 题解 P2320 【[HNOI2006]鬼谷子的钱袋】

    P2320 [HNOI2006]鬼谷子的钱袋 挺有趣的一道题,之所以发这篇题解是因为感觉思路的更清晰一点qwq 此题主要有两种方法: 一.分治思想 例如要凑出1~20,假如我们已经能凑出1~10了,那 ...

  5. 编译和链接(lib和dll区别)(转载)

    1.头文件并不参加链接和编译.编译器第一步要做的就是简单的把头文件在包含它的源文件中展开.不知你是否能理解这句话.也就是头文件里面有什么内容,通通把它移到包含这个头文件的源文件里.(我觉得这是个很重要 ...

  6. 6_11 四分树(UVa297)<四分树>

    一幅图有1024个点, 可以对图平均分成4块, 并且子图也可以再往下分, 直到一个子图表示一个点. f表示这块子图填满, p表示它还有4个子图, e表示没有子图(当然啦, 它也没有填满). 给定两个字 ...

  7. js语言简介

    JS语言概述 JS语言简史 JS语言的起源 网景(Netscape Communication Corperation),1994年,推出第一款商用浏览器,网景浏览器(Netscape Navigat ...

  8. 吴裕雄 python 机器学习——人工神经网络感知机学习算法的应用

    import numpy as np from matplotlib import pyplot as plt from sklearn import neighbors, datasets from ...

  9. Chrome - 使用 开发者工具 对页面截图

    概述 使用 开发者工具 对页面截图 背景 经常需要截图 常用的截图模式有这些 窗口截图 区域截图 gif 问题 Chrome 如何截长图 firefox 好像有插件 1. 解决: 使用 Chrome ...

  10. Git - 06. git checkout

    1. 概述 已经学会查看 提交记录 尝试在 提交记录 之间做跳转 2. 命令 跳转到提交 概述 跳转到 日志 里的某次提交 命令 # 撤销 工作区的所有改动, 返回 当前分支 的 上一个提交 > ...