水题,分组排序即可。

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h> using namespace std;
/*
太水水水。。。
*/
const int maxn=+;
int cnt1,cnt2,cnt3,cnt4;
struct Node{
int id;
int tot;
int vir;
int tal;
bool operator<(const Node tmp)const{
if(tot==tmp.tot){
if(vir==tmp.vir)
return id<tmp.id;
else
return vir>tmp.vir;
}
else
return tot>tmp.tot; }
}sages[maxn],noble[maxn],fool[maxn],small[maxn]; int main()
{
int n,L,H;
int a,b,c;
scanf("%d %d %d",&n,&L,&H);
for(int i=;i<=n;i++){
scanf("%d %d %d",&a,&b,&c);
if(b<L || c<L)
continue;
if(b>=H && c>=H){
sages[cnt1].id=a;
sages[cnt1].vir=b;
sages[cnt1].tal=c;
sages[cnt1].tot=b+c;
cnt1++;
}
else if(b>=H && c<H && c>=L){
noble[cnt2].id=a;
noble[cnt2].vir=b;
noble[cnt2].tal=c;
noble[cnt2].tot=b+c;
cnt2++;
}
else if(b<H && c<H &&b>=c){
fool[cnt3].id=a;
fool[cnt3].vir=b;
fool[cnt3].tal=c;
fool[cnt3].tot=b+c;
cnt3++;
}
else{
small[cnt4].id=a;
small[cnt4].vir=b;
small[cnt4].tal=c;
small[cnt4].tot=b+c;
cnt4++;
}
}
sort(sages,sages+cnt1);
sort(noble,noble+cnt2);
sort(fool,fool+cnt3);
sort(small,small+cnt4);
printf("%d\n",cnt1+cnt2+cnt3+cnt4);
for(int i=;i<cnt1;i++){
printf("%08d %d %d\n",sages[i].id,sages[i].vir,sages[i].tal);
}
for(int i=;i<cnt2;i++){
printf("%08d %d %d\n",noble[i].id,noble[i].vir,noble[i].tal);
}
for(int i=;i<cnt3;i++){
printf("%08d %d %d\n",fool[i].id,fool[i].vir,fool[i].tal);
}
for(int i=;i<cnt4;i++){
printf("%08d %d %d\n",small[i].id,small[i].vir,small[i].tal);
}
return ;
}

PAT甲题题解-1062. Talent and Virtue (25)-排序水题的更多相关文章

  1. PAT甲题题解-1012. The Best Rank (25)-排序水题

    排序,水题因为最后如果一个学生最好的排名有一样的,输出的课程有个优先级A>C>M>E那么按这个优先级顺序进行排序每次排序前先求当前课程的排名然后再与目前最好的排名比较.更新 至于查询 ...

  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 甲级 1062 Talent and Virtue (25 分)(简单,结构体排序)

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

  5. PAT甲题题解-1019. General Palindromic Number (20)-又是水题一枚

    n转化为b进制的格式,问你该格式是否为回文数字(即正着写和倒着写一样)输出Yes或者No并且输出该格式又是水题... #include <iostream> #include <cs ...

  6. 1062 Talent and Virtue (25)

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

  7. pat 1062. Talent and Virtue (25)

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

  8. PAT甲题题解-1125. Chain the Ropes (25)-贪心水题

    贪心水题,每次取最短的两个绳子合并,长度缩减成一半 #include <iostream> #include <cstdio> #include <algorithm&g ...

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

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

随机推荐

  1. Spring IOC容器创建bean过程浅析

    1. 背景 Spring框架本身非常庞大,源码阅读可以从Spring IOC容器的实现开始一点点了解.然而即便是IOC容器,代码仍然是非常多,短时间内全部精读完并不现实 本文分析比较浅,而完整的IOC ...

  2. initialProps被React-Navigation的navigation属性覆盖解决方案

    怎么开场对我来说一个是个很纠结的问题,Emmm这应该算个好开场. 最近在做一个RN的app端调试工具,在把它嵌入原生app中的时候遇到了一个问题,RN组件里面接受不到原生传过来的initialProp ...

  3. python第三十课--异常(异常处理定义格式和常见类型)

    演示: 1).异常处理的定义格式: 2).常见的运行时异常类型: try: print(10/0) num=int('132a') except Exception as e: print('出错了. ...

  4. 1.HBase In Action 第一章-HBase简介(后续翻译中)

    This chapter covers ■ The origins of Hadoop, HBase, and NoSQL ■ Common use cases for HBase ■ A basic ...

  5. thinkphp5整合 gatewaywork实现聊天

    1:将下载的gatewaywork下的\vendor  下的workman文件夹,整个复制到tp5下的vendor目录下 2:tp5\application\push   新键push文件夹,将下载的 ...

  6. ssh推送.py程序到服务器端运行

    C:\Users\jiangshan>ssh jiangshan@192.168.1.191jiangshan@192.168.1.191's password:Last login: Sun ...

  7. C# 匿名类型var

    格式: var 名字=new {字段赋值}:c#中只是作为推断,根据赋值推断出类型,隐式类型 var. 隐式类型的本地变量是强类型变量(就好像您已经声明该类型一样),但由编译器确定类型. 1)var类 ...

  8. linux找到目录下所有目录文件

    想要删除掉该目录下的所有文件类型是目录的文件? 这样运行: $ ls -F | grep /$ | xargs rm -rf ls 中F参数,作用是能把目录文件的名字后边加上一个斜杠/ 然后匹配以斜杠 ...

  9. php中addslashes(),htmlspecialchars()

    参考转自http://czf2008700.blog.163.com/blog/static/2397283200937103250194/ addslashes -- 使用反斜线引用字符串 stri ...

  10. PI monitor error process-RESOURCE_NOT_FOUND-转

    事务:sxi_monitor 状态:system error 类型:Request Message Mapping 错误简要:RESOURCE_NOT_FOUND 错误详细信息: <?xml v ...