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> ...
随机推荐
- Alpha事后诸葛亮(阳光普照队)
Alpha事后诸葛亮 设想和目标 1.实现文字识别,以用户喜欢的图片做背景将其保存,生成新的图片. 2.时间比较赶,主要是因为队员对于Android开发方面的了解不多,可以说是几乎没有,需要一步一步的 ...
- Linux命令一览
Linux系统中的命令参数有长短格式之分,长格式和长格式之间不能合并,长格式和短格式之间也不能合并,但短格式和短格式之间是可以合并的,合并后仅保留一个-(减号)即可. echo命令:用于在终端输出字符 ...
- ArcGIS API for Javascript之专题图的制作(四)热力图渲染(上)
一 .热力图定义 热力图(heat map)也称热图,是以特殊颜色高亮区域的形式表示密度.温度.气压.频率等分布的不易理解和表达的数据. 二.HeatmapRenderer esri/renderer ...
- nginx之location.md
安装echo模块 下载模块 # pwd /root # git clone https://github.com/openresty/echo-nginx-module 重新编译 先查看版本,然后根据 ...
- 解决Matlab当中for循环运行慢的问题
做量化操作的时候经常需要使用到matlab编写策略或者计算多因子,for循环非常慢,自己找了一些matlab中for循环的优化方法,for的部分每处理一个大矩阵都要花费大量的时间,这是不可避免需要遇到 ...
- 3-51单片机ESP8266学习-AT指令(学会刷固件)
前言:体验一下刷固件(给单片机更新程序) 上一篇链接 http://www.cnblogs.com/yangfengwu/p/8757036.html 源码链接:https://pan.baidu. ...
- 二分法php
二分法.分别使用while循环的方法和递归调用的方法. <?php // 二分法的使用数组必须是有序的,或升序,或降序 $arr = array( 1, 3, 5, 7, 9, 13 ); // ...
- VBA 连接,提醒 rs AS new adodb.recordset 的变量未定义
解决方法: 菜单-工程-引用Microsoft ActiveX Data Objects 2.x Library 定位……msado15.dll
- Android开发四大组件之Service(具体解释篇)
Android开发之四大组件--Service 一.Service 简单介绍 Service是android系统中的四大组件之中的一个(Activity.Service.BroadcastReceiv ...
- stop-hbase.sh一直处于等待状态
今天关闭HBase时,输入stop-hbase.sh一直处于等待状态 解决方法: 先输入:hbase-daemon.sh stop master 再输入:stop-hbase.sh就可以关闭HBase ...