PAT1015德才论

#include<stdio.h>
#include<algorithm>
using namespace std;
struct node{
int id,de,cai;
}one[100001],two[100001],three[100001],four[100001];
bool cmp(struct node a,struct node b)
{
int suma = a.cai+a.de;
int sumb = b.cai+b.de;
if(suma != sumb) return suma > sumb;
else if(a.de != b.de) return a.de > b.de;
else return a.id < b.id;
}


int main()
{
int i = 0,j = 0,k = 0,p = 0,t;
int count = 0;
int num,low,high;
int a,b,c;
scanf("%d %d %d",&num,&low,&high);
while(num--)
{
scanf("%d%d%d",&a,&b,&c);
if(b >= low && c >= low)
{
count++;
if(b >= high && c >= high)
{
one[i].id = a;
one[i].de = b;
one[i].cai = c;
i++;
}
else if(b >= high && c < high)
{
two[j].id = a;
two[j].de = b;
two[j].cai = c;
j++;
}
else if(b < high && c < high && b >= c)
{
three[k].id = a;
three[k].de = b;
three[k].cai = c;
k++;
}
else
{
four[p].id = a;
four[p].de = b;
four[p].cai = c;
p++;
}
}
}
sort(one,one+i,cmp);
sort(two,two+j,cmp);
sort(three,three+k,cmp);
sort(four,four+p,cmp);
printf("%d\n",count);
for(t = 0;t < i;t++)
{
printf("%d %d %d\n",one[t].id,one[t].de,one[t].cai);
}
for(t = 0;t < j;t++)
{
printf("%d %d %d\n",two[t].id,two[t].de,two[t].cai);
}
for(t = 0;t < k;t++)
{
printf("%d %d %d\n",three[t].id,three[t].de,three[t].cai);
}
for(t = 0;t < p;t++)
{
printf("%d %d %d\n",four[t].id,four[t].de,four[t].cai);
}
return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值