简单排序。题意较长。

#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. 线程中sleep方法和wait方法有什么区别?

    如果你没有接触过java的多线程,那么多对于这两个方法可能有点陌生,看名字好像这两个方法是差不多的,但是实际上面差别好大. 首先我们看一下官方的API Sleep(sleep有两个方法,另一个方法传递 ...

  2. python 常用

    1. dir()             不带参数时,返回当前范围内的变量.方法和定义的类型列表:带参数时,返回参数的属性.方法列表.如果参数包含方法__dir__(),该方法将被调用.如果参数不包含 ...

  3. hdu_2111_Saving HDU(贪心)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=2111 题意:给你n个物品的单位体积价值和体积,求装满容量v的背包的最大价值. 题解:乍一看还以为是背包 ...

  4. 关于Spring Security 3获取用户信息的问题

    标签: spring security 3标签获取用户信息 2013-01-05 10:40 5342人阅读 评论(0) 收藏 举报  分类: Spring(25) java(70) 前端(7)    ...

  5. px和sp什么区别

    都表示像素,只不过sp通常表示文字大小: <TextView android:layout_width="wrap_content" android:layout_heigh ...

  6. Linux 终端下颜色的输出

    在命令行下也能产生五颜六色的字体和图案,只需要加上一些颜色代码,例如 echo -e "\033[41;36m 红底绿字\033[0m" 其中41的位置代表底色, 36的位置是代表 ...

  7. 登录数据库后,use db很慢的问题

    mysql> use dbl Reading table information for completion of table and column names You can turn of ...

  8. URL设置问题

    URL设置那里删除了<item path="index.aspx" pattern="index.aspx"/>后,访问首页就不出来了,要加上/in ...

  9. ignite中的sql查询

    ignite中进行sql查询需要对要查询的cache和字段进行配置,可以在xml中配置,也可以在代码中配置或进行注解,我用的是xml配置: <!-- 配置cache --> <pro ...

  10. Stammering Aliens

    Stammering Aliens Time Limit: 2000MS   Memory Limit: 65536K       Description Dr. Ellie Arroway has ...