#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct people{
char id[16];
int tanlent;
int vietue;
int clas;
}peo[100010];
bool cmp(people a, people b){
if( a.clas!=b.clas )return a.clas<b.clas;
else if((a.vietue+a.tanlent)!=(b.vietue+b.tanlent)) return (a.vietue+a.tanlent)>(b.vietue+b.tanlent);
else if(a.vietue!=b.vietue) return a.vietue>b.vietue;
else return strcmp(a.id,b.id)<0;
}
int main(){
int i, n, low, high, m=0;
scanf("%d%d%d",&n,&low,&high); //输入n,low,high
for(i=0;i<n;i++){
scanf("%s%d%d",peo[i].id,&peo[i].vietue,&peo[i].tanlent); //输入具体数据
if(peo[i].vietue>=low&&peo[i].tanlent>=low){m++;
if(peo[i].vietue>=high&&peo[i].tanlent>=high){peo[i].clas=1;}
if(peo[i].vietue>=high&&peo[i].tanlent<high){peo[i].clas=2;}
if(peo[i].vietue<high&&peo[i].vietue>=peo[i].tanlent){peo[i].clas=3;}
if(peo[i].vietue<high&&peo[i].vietue<peo[i].tanlent){peo[i].clas=4;}
}
else peo[i].clas=5;
}
sort(peo,peo+n,cmp);
printf("%d\n",m);
for(i=0;i<m;i++){
printf("%s %d %d\n",peo[i].id, peo[i].vietue,peo[i].tanlent);
}
return 0;
}
PAT-B1015
最新推荐文章于 2021-09-16 13:27:21 发布