水题,分组排序即可。

#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. 自己模拟写C++中的String类型

    下面是模拟实现字符串的相关功能,它包括一下功能:    String(const char * s);//利用字符串来初始化对象    String(); //默认构造函数    String(con ...

  2. 团队作业——Beta冲刺3

    团队作业--Beta冲刺 冲刺任务安排 杨光海天 今日任务:浏览详情界面的开发 明日任务:浏览详情界面的开发 吴松青 今日任务:与队长一同进行图片详情的开发,接触了一些自己没接触过的知识点并向队友学习 ...

  3. css多行省略-webkit-box-orient打包编译后失效原因

    原css代码: .dialog-for-plan .dialog-table .type>p { display: -webkit-box; -webkit-box-orient: vertic ...

  4. ES6对抽象工厂模式与策略模式结合的实践

    这段代码是我在学习了java版的抽象工厂模式后,实现的ES6版抽象工厂,后期大幅修改,加入了策略模式,看起来很多逻辑看似繁琐,不必要写这么多,但是为了练习设计模式,所以才这样做.当所需的工厂种类增多后 ...

  5. BZOJ4269:再见Xor(线性基)

    Description 给定N个数,你可以在这些数中任意选一些数出来,每个数可以选任意多次,试求出你能选出的数的异或和的最大值和严格次大值. Input 第一行一个正整数N. 接下来一行N个非负整数. ...

  6. stl vector、红黑树、set、multiset、map、multimap、迭代器失效、哈希表(hash_table)、hashset、hashmap、unordered_map、list

    stl:即标准模板库,该库包含了诸多在计算机科学领域里所常用的基本数据结构和基本算法 六大组件: 容器.迭代器.算法.仿函数.空间配置器.迭代适配器 迭代器:迭代器(iterator)是一种抽象的设计 ...

  7. linux服务器关闭ipv6 方法

    第一个文件: /etc/sysconfig/network 第二个文件:如无此文件,vim添加 /etc/modprobe.d/disable_ipv6.conf

  8. 解决php编译报错configure: error: mcrypt.h not found. Please reinstall libmcrypt.

    yum install -y epel-releaseyum install -y libmcrypt-devel

  9. (转)CloudStack 安装及使用过程中常见问题汇总

    CloudStack 安装及使用过程中常见问题汇总             在做工程项目中对CloudStack 安装及使用过程中常见的几个问题及如何解决做一个总结.   1.Windows XP虚拟 ...

  10. 计算机视觉-sift(2)代码理解

    之前结合不同人的资料理解了sift的原理,这里通过opencv中的代码来加深对sift的实现的理解. 使得能够从原理性理解到源码级的理解.不过该博文还是大量基于<赵春江, opencv2.4.9 ...