PAT (Advanced Level) 1062. Talent and Virtue (25)
简单排序。题意较长。
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#include<string>
#include<stack>
#include<map>
#include<algorithm>
using namespace std; struct X
{
int id;
int v,t;
int f;
}s[+],tmp[+],Ans[+];
int n,L,H;
int tot; bool cmp(const X&a,const X&b)
{
if(a.t+a.v==b.t+b.v&&a.v==b.v) return a.id<b.id;
if(a.t+a.v==b.t+b.v) return a.v>b.v;
return a.t+a.v>b.t+b.v;
} int main()
{
scanf("%d%d%d",&n,&L,&H);
for(int i=;i<=n;i++) scanf("%d%d%d",&s[i].id,&s[i].v,&s[i].t);
for(int i=;i<=n;i++) s[i].f=; for(int i=;i<=n;i++) if(s[i].t<L||s[i].v<L) s[i].f=; tot=;
int ans=; for(int i=;i<=n;i++)
{
if(s[i].f==) continue;
if(s[i].t>=H&&s[i].v>=H)
{ tmp[tot++]=s[i];
s[i].f=;
}
} sort(tmp,tmp+tot,cmp);
for(int i=;i<tot;i++) Ans[ans++]=tmp[i];
tot=; for(int i=;i<=n;i++)
{
if(s[i].f==) continue;
if(s[i].t<H&&s[i].v>=H)
{ tmp[tot++]=s[i];
s[i].f=;
}
} sort(tmp,tmp+tot,cmp);
for(int i=;i<tot;i++) Ans[ans++]=tmp[i];
tot=; for(int i=;i<=n;i++)
{
if(s[i].f==) continue;
if(s[i].t<H&&s[i].v<H&&s[i].v>=s[i].t)
{ tmp[tot++]=s[i];
s[i].f=;
}
} sort(tmp,tmp+tot,cmp);
for(int i=;i<tot;i++) Ans[ans++]=tmp[i];
tot=; for(int i=;i<=n;i++)
{
if(s[i].f==) continue; tmp[tot++]=s[i];
s[i].f=; } sort(tmp,tmp+tot,cmp);
for(int i=;i<tot;i++) Ans[ans++]=tmp[i];
tot=; printf("%d\n",ans);
for(int i=;i<ans;i++)
{
printf("%08d %d %d\n",Ans[i].id,Ans[i].v,Ans[i].t);
}
return ;
}
PAT (Advanced Level) 1062. Talent and Virtue (25)的更多相关文章
- 【PAT甲级】1062 Talent and Virtue (25 分)
题意: 输入三个正整数N,L,H(N<=1E5,L>=60,H<100,H>L),分别代表人数,及格线和高水平线.接着输入N行数据,每行包括一个人的ID,道德数值和才能数值.一 ...
- 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 ...
- 1062 Talent and Virtue (25)
/* L (>=60), the lower bound of the qualified grades -- that is, only the ones whose grades of ta ...
- 1062 Talent and Virtue (25分)(水)
About 900 years ago, a Chinese philosopher Sima Guang wrote a history book in which he talked about ...
- pat 1062. Talent and Virtue (25)
难得的一次ac 题目意思直接,方法就是对virtue talent得分进行判断其归属类型,用0 1 2 3 4 表示 不合格 sage noblemen foolmen foolmen 再对序列进行排 ...
- PAT甲题题解-1062. Talent and Virtue (25)-排序水题
水题,分组排序即可. #include <iostream> #include <cstdio> #include <algorithm> #include < ...
- PAT (Advanced Level) 1113. Integer Set Partition (25)
简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...
- PAT (Advanced Level) 1110. Complete Binary Tree (25)
判断一棵二叉树是否完全二叉树. #include<cstdio> #include<cstring> #include<cmath> #include<vec ...
随机推荐
- allocator 类
allcator是一个模板类 定义在memory头文件中,将内存分配与对象构造分开,分配的内存是原始的.未构造的 一.how to use 因其实一个类,则使用allcator时需要首先声明一个类对象 ...
- nodejs 命令篇
1.npm init // 生成package.json 2.npm install --save-dev gulp-jslint // 安装gulp-jslint模块,并把模块名和版本保存到pack ...
- Fibonacci 数列第 N项 O(logN)算法
时间复杂度为O( log n )的方法: 该算法使用矩阵乘法操作,使得算法时间复杂度为 O(logN) long long Fibonacci( unsigned n ) { ] = {, }; ) ...
- 在Javascript中使用protobuf与c++进行通信
环境:Win7_64旗舰版,VS2013 最近在研究Webkit,已经编译成功,接下来就是Javascript与c++如何传输数据,立刻就想到了protobuf,但是谷歌不支持Javascript,百 ...
- web配置文件的<load-on-startup>0</load-on-startup>
在servlet的配置当中,<load-on-startup>5</load-on-startup>的含义是:标记容器是否在启动的时候就加载这个servlet.当值为0或者大于 ...
- linux系统定时重启tomcat
#touch auto-start.sh [root@Linux opt]# echo $LANGen_US.UTF-8 #vim auto-start.sh #!/bin/sh export LAN ...
- 基础-Ajax,json
ajax是异步交互,也就是说发送请求,到响应回来,页面只是局部刷新. Ajax 步骤: 获取XMLHttpRequest对象 绑定一个回调函数 open send 在回调函数中完成操作. json是一 ...
- dl以及dt,dd,以及table的tr,th,td最清楚分析
1,定义:<dl> <dt> <dd>是一组合标签,使用了dt dd最外层就必须使用dl包裹,此组合标签我们也又叫表格标签,与table表格类似组合标签,故名我们也 ...
- android 定时器总结
1:handler实现定时器的功能 Handler handler=new Handler(); //立即执行Runnable对象 public final boolean post(Runnab ...
- Mybatis学习(5)高级映射
需求: 一.一对一查询 查询订单信息,关联查询创建订单的用户信息: orders--->user:一个订单只由一个用户创建,一对一 orders表 和 user表: 1)使用resultType ...