Result: Accepted
Time: 162ms
Memory: 3712kB
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
using namespace std;
int x,y,z,n,t,k,l,h,cnt,temp;
const int maxn=100010;
struct student{
int id,iq,face,sum,flag;
}node[maxn];
bool cmp (student a,student b){
if(a.flag!=b.flag)
return a.flag>b.flag;
else if(a.sum!=b.sum)
return a.sum>b.sum;
else if(a.iq!=b.iq)
return a.iq>b.iq;
else return a.id<b.id;
}
int main(){
scanf("%d%d%d",&n,&l,&h);
cnt=0;
for(int i=0;i<n;i++){
scanf("%d %d %d",&node[i].id,&node[i].iq,&node[i].face);
node[i].sum=node[i].face+node[i].iq;
if(node[i].face>=h&&node[i].iq>=h)
node[i].flag=4;
else if(node[i].face>=l&&node[i].face<h&&node[i].iq>=h)
node[i].flag=3;
else if(node[i].face>=l&&node[i].face<h&&node[i].iq<h&&node[i].iq>=l&&node[i].iq>=node[i].face)
node[i].flag=2;
else if(node[i].face<l||node[i].iq<l)
node[i].flag=0;
else node[i].flag=1;
if(node[i].flag!=0)
cnt++;
}
sort(node,node+n,cmp);
printf("%d\n",cnt);
for(int i=0;i<cnt;i++){
printf("%d %d %d\n",node[i].id,node[i].iq,node[i].face);
}
return 0;
}