Start: Jul, 05, 2019 08:40:00
2019年度暑期短学期达标测试
End: Jul, 05, 2019 11:40:00
Time elapsed:
Time remaining:

Problem_ID: K
Result: Accepted
Time: 162ms
Memory: 3712kB
Author: CT12812411281
In contest: 1281

#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;
}