PAT甲题题解-1062. Talent and Virtue (25)-排序水题
水题,分组排序即可。
#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)-排序水题的更多相关文章
- PAT甲题题解-1012. The Best Rank (25)-排序水题
排序,水题因为最后如果一个学生最好的排名有一样的,输出的课程有个优先级A>C>M>E那么按这个优先级顺序进行排序每次排序前先求当前课程的排名然后再与目前最好的排名比较.更新 至于查询 ...
- 1062 Talent and Virtue (25分)(水)
About 900 years ago, a Chinese philosopher Sima Guang wrote a history book in which he talked about ...
- 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 ...
- PAT 甲级 1062 Talent and Virtue (25 分)(简单,结构体排序)
1062 Talent and Virtue (25 分) About 900 years ago, a Chinese philosopher Sima Guang wrote a histor ...
- PAT甲题题解-1019. General Palindromic Number (20)-又是水题一枚
n转化为b进制的格式,问你该格式是否为回文数字(即正着写和倒着写一样)输出Yes或者No并且输出该格式又是水题... #include <iostream> #include <cs ...
- 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甲题题解-1125. Chain the Ropes (25)-贪心水题
贪心水题,每次取最短的两个绳子合并,长度缩减成一半 #include <iostream> #include <cstdio> #include <algorithm&g ...
- PAT (Advanced Level) 1062. Talent and Virtue (25)
简单排序.题意较长. #include<cstdio> #include<cstring> #include<cmath> #include<queue> ...
随机推荐
- vue+axios自己踩过的坑
axios的介绍就不用了吧,api有具体的介绍axios或者是axios中文: 主要讲的就是我自己在第一次使用axios中遇到的问题,及二次封装 先来说说二次封装,之前自己也是网上找了很多同学的封装, ...
- C++类中的特殊成员函数-------复制构造函数
在C++中存在一个特殊函数,他就是复制构造函数,假如我们有类A,如果有A a;A b=a; 在这种情况下利用A类变量a来给同是A类变量的b来赋值,这个时候类会使用复制构造函数,如果我们不显式声明复 ...
- SQLServer 删除表中的重复数据
create table Student( ID varchar(10) not null, Name varchar(10) not null, ); insert in ...
- Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine
在开发中用到Microsoft.ACE.OLEDB.12.0,但是,出现了Microsoft.ACE.OLEDB.12.0' provider is not registered on the l ...
- Android常见UI组件之ListView(一)
使用ListView显示一个长的项列表 1.新建一个名为"BasicView5"的Android项目. 2.改动BasicView5.java文件.改动后的程序例如以下: pack ...
- Volley源码分析(四)NetWork与ResponseDelivery工作原理
这篇文章主要分析网络请求和结果交付的过程. NetWork工作原理 之前已经说到通过mNetWork.performRequest()方法来得到NetResponse,看一下该方法具体的执行流程,pe ...
- JAVA框架 Spring 调用jdbcsuport简化开发
一)使用DAO的jdbcsuport来简化开发 首先来清楚一个概念: 我们在进行配置文件来进行依赖注入的时候,主要是通过set方法来进行设置的. 正常我们使用spring的jdbctemplate的时 ...
- BiCMOS技术
BiCMOS技术 编辑 本词条由“科普中国”百科科学词条编写与应用工作项目 审核 . 把双极型晶体管(BJT)和CMOS器件同时集成在同一块芯片上的新型的工艺技术,它集中了上述单.双极型器件的优点,两 ...
- CAN总线几种正常的“异常”波形
CAN总线几种正常的“异常”波形 [复制链接] 电梯直达 楼主 hubaba 发表于 2016-3-28 14:00 | 只看该作者 摘要 工程师们通常使用示波器观察CAN总线的信 ...
- 网络对抗技术 2017-2018-2 20152515 Exp6 信息搜集与漏洞扫描
1.实践目标 掌握信息搜集的最基础技能与常用工具的使用方法.包括: (1)各种搜索技巧的应用 (2)DNS IP注册信息的查询 (3)基本的扫描技术:主机发现.端口扫描.OS及服务版本探测.具体服务的 ...