简单排序。题意较长。

#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)的更多相关文章

  1. 【PAT甲级】1062 Talent and Virtue (25 分)

    题意: 输入三个正整数N,L,H(N<=1E5,L>=60,H<100,H>L),分别代表人数,及格线和高水平线.接着输入N行数据,每行包括一个人的ID,道德数值和才能数值.一 ...

  2. 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 ...

  3. PAT 甲级 1062 Talent and Virtue (25 分)(简单,结构体排序)

    1062 Talent and Virtue (25 分)   About 900 years ago, a Chinese philosopher Sima Guang wrote a histor ...

  4. 1062 Talent and Virtue (25)

    /* L (>=60), the lower bound of the qualified grades -- that is, only the ones whose grades of ta ...

  5. 1062 Talent and Virtue (25分)(水)

    About 900 years ago, a Chinese philosopher Sima Guang wrote a history book in which he talked about ...

  6. pat 1062. Talent and Virtue (25)

    难得的一次ac 题目意思直接,方法就是对virtue talent得分进行判断其归属类型,用0 1 2 3 4 表示 不合格 sage noblemen foolmen foolmen 再对序列进行排 ...

  7. PAT甲题题解-1062. Talent and Virtue (25)-排序水题

    水题,分组排序即可. #include <iostream> #include <cstdio> #include <algorithm> #include < ...

  8. PAT (Advanced Level) 1113. Integer Set Partition (25)

    简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...

  9. PAT (Advanced Level) 1110. Complete Binary Tree (25)

    判断一棵二叉树是否完全二叉树. #include<cstdio> #include<cstring> #include<cmath> #include<vec ...

随机推荐

  1. C++primer 9.43

    题目要求:编写一个函数,接受三个string参数s,oldVal和newVal.使用迭代器及insert和erase函数将s中所有oldVal替换为newVal.测试你的程序,用它替换通用的简写形式, ...

  2. 在vim中使用perltidy美化perl代码

    来源: http://www.cnblogs.com/itech/archive/2013/02/18/2915279.html 格式优美的perl代码不但让人赏心悦目,而且可以方便阅读. perlt ...

  3. Glusterfs 分布式存储安装部署

    Glusterfs 分布式存储部署 是存储当中可以选择的一种 现在很多虚拟化 云计算都在用软件存储 例如 ceph Glusterfs 等等 今天我们部署一下Glusterfs环境 GlusterFs ...

  4. C#设置默认打印机

    项目中,需要选择打印机,切换打印机.demo如下(wpf应用程序): Xaml: <Window x:Class="PrintersApp.MainWindow" xmlns ...

  5. 转 如何不耍流氓的做运维之——SHELL脚本

    家都是文明人,尤其是做运维的,那叫一个斯文啊.怎么能耍流氓呢?赶紧看看,编写 SHELL 脚本如何能够不耍流氓. 下面的案例,我们以 MySQL 数据库备份 SHELL 脚本的案例来进行阐述. 不记录 ...

  6. TCP数据包结构

    源端口号( 16 位):它(连同源主机 IP 地址)标识源主机的一个应用进程.目的端口号( 16 位):它(连同目的主机 IP 地址)标识目的主机的一个应用进程.这两个值加上 IP 报头中的源主机 I ...

  7. Lua基础(一)

    1.Lua中有8个基本类型分别为:nil.boolean.number.string.userdata.function.thread和table 2.Lua中的表达式包括数字常量.字符串常量.变量. ...

  8. php 10.1总

    在做添加时写是否已经有该文件 $_sql1 = "SELECT * FROM tb_user where userName = {$_clean['userName']} "; $ ...

  9. web工程中地址的写法

    硬盘地址用\   如:c:\\ 虚拟地址用 / /* 只要是写地址,建议大家最好以"/"开头,/到底代表什么呢? 1.看这个地址是给服务器用的,还是给浏览器用的. 2.如果给浏览器 ...

  10. 构建一个最简单的web应用并部署及启动

    第一种构建方式:不使用maven File-new-Dynamic Web Project,用这种方式构建的web项目是在web.xml文件中配置了welcome-file的,但是却没有对应的文件,所 ...