水题,分组排序即可。

#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. Apache的权限设置与构建虚拟web主机

    实验拓扑图: 实验要求: 1.  搭建WEB服务器,能访问默认站点,并使用awstats软件能监控到默认站点的访问情况. 2.  修改Apache的主配置文件,设置1.10只能访问awstats网站, ...

  2. phpstorm添加laravle语法支持

    PHPStorm神器可以支持更友好的laravel框架代码提示,只需要执行如下才做: 第一步:在项目的composer.json中添加如下一行 "require": { " ...

  3. Python3编写网络爬虫01-基本请求库urllib的使用

    安装python后 自带urllib库 模块篇 分为几个模块如下: 1. urllib.request 请求模块 2. urllib.parse 分析模块 3. urllib.error 异常处理模块 ...

  4. Android-硬件加速

    转载请注明来源:http://blog.csdn.net/goldenfish1919/article/details/36890475 从3.0(API level 11)開始.Android 2D ...

  5. Android Bitmap Drawable byte[] InputStream 相互转换方法

    用android处理图片的时候,由于得到的资源不一样,所以经常要在各种格式中相互转化,以下介绍了 Bitmap Drawable byte[] InputStream 之间的转换方法: import ...

  6. [POI2007]MEG-Megalopolis

    传送门:嘟嘟嘟 第一反应是树链剖分,但是太长懒得写,然后就想出了一个很不错的做法. 想一下,如果我们改一条边,那么影响的只有他的子树,只要先搞一个dfs序,为什么搞出这个呢?因为有一个性质:一个节点的 ...

  7. UI之富文本编辑器-UEditor

    在做Web应用时,经常会进行富文本编辑,常用的富文本编辑器有很多,比如CuteEditor.CKEditor.NicEditor.KindEditor.UEditor等等. 在这里为大家推荐百度推出的 ...

  8. 软件测试QA、QC、QM的关系与区别

    01概念上 QA:Quality Assurance (质量保证) QC:Quality Control (质量控制) QM:Quality Manage (质量管理) 02定义上 QA:为达到质量要 ...

  9. 使用 rem 作为单位使页面自适应设备宽度

    一.新建 rem.js 文件,代码如下: export default function () { document.documentElement.style.fontSize = document ...

  10. Jmeter核心-hc课堂笔记

    自动化测试平台-Httprunner-接口.UI.协议. 平台语言-JAVA-UI-Selenium(java版的).Appium(java版的).接口-Httpclient.Jmeter.(Jmet ...