简单排序。题意较长。

#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. nginx 实现Web应用程序的负载均衡

    文章转载自 博客园, 原文地址 http://www.cnblogs.com/ivanyb/archive/2011/11/16/2250710.html 看到园子中的大牛代震军写的一篇玩玩负载均衡- ...

  2. 其他应用和技巧-用Json格式来保存数据

    -------------------- <script type="text/javascript">            //定义json变量           ...

  3. hdu_Anniversary party_(树形DP入门题)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1520 题意:有N个人,N-1个人有自己的上司,每个人有一个快乐值,如果这个人参加了聚会,那么这个人的直 ...

  4. HDU1711:Number Sequence

    Problem Description Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b[2], .... ...

  5. Mac下截图快捷键

    Cmd+Shift+3:全屏截图:截取整个屏幕,保存截图至桌面文件夹.Cmd+Shift+4:区域截图:鼠标光标变成带坐标的小十字,通过拖拽截取特定区域,保存截图至桌面文件夹.Cmd+Shift+4 ...

  6. AFNetWorking 判断当前版本是否是最新版本

    NSString *url = [[NSString alloc] initWithFormat:@"http://itunes.apple.com/lookup?id=%@",@ ...

  7. perl命令+关键字

    来源: http://www.cnblogs.com/itech/archive/2012/11/01/2749666.html http://www.garybeene.com/vb/tut-per ...

  8. Boost的VS开发环境搭建

    1. 下载并解压Boost C++ Libs 下载地址: SourceForge:http://sourceforge.net/projects/boost/files/boost/1.48.0/ B ...

  9. 移植iw 到linux平台上。

    https://github.com/174high/iw-3.7-Linux-porting https://github.com/174high/libnl-1.1-stable-master-l ...

  10. 【jsp 分页】mysql limit方式进行分页

    项目结构示意图: splitPage |-com.balfish.bean     Goods.java |-com.balfish.dao       GoodsDao.java |-com.bal ...