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: 637ms
Memory: 3712kB
Author: CT12812861281
In contest: 1281

#include <cstdio>
#include <iostream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int t,n,l,h;
const int maxn=1e5+7;
struct node
{
	int num;
	int IQ;
	int face;
	int tot;
	int grade;
}stu[maxn];
bool comp(node a,node b)
{
	if(a.grade<b.grade) return true;
	else if(a.grade>b.grade) return false;
	else if(a.grade==b.grade)
	{
		if(a.tot>b.tot) return true;
		else if(a.tot<b.tot) return false;
		else if(a.tot==b.tot)
		{
			if(a.IQ>b.IQ) return true;
			else if(a.IQ<b.IQ) return false;
			else if(a.IQ==b.IQ)
			{
				if(a.num<b.num) return true;
				else
					return false;
			}
		}
	}
}

int main()
{
	cin>>n>>l>>h;
	int a,b,c;
	int cnt=-1;
	for(int i=0;i<n;i++)
	{
		cin>>a>>b>>c;
		if(b<l||c<l)
			continue;
		cnt++;
		stu[cnt].num=a;stu[cnt].IQ=b;stu[cnt].face=c;
		stu[cnt].tot=stu[cnt].IQ+stu[cnt].face;
	}
	cnt++;
	for(int i=0;i<cnt;i++)
	{
		if(stu[i].IQ>=h&&stu[i].face>=h)
			stu[i].grade=1;
		else if(stu[i].IQ>=h&&stu[i].face<h)
			stu[i].grade=2;
		else if(stu[i].IQ<h&&stu[i].face<h&&stu[i].IQ>=stu[i].face)
			stu[i].grade=3;
		else
			stu[i].grade=4;
	}
	sort(stu,stu+cnt,comp);
	cout<<cnt<<endl;
	for(int i=0;i<cnt;i++)
	{
		cout<<stu[i].num<<" "<<stu[i].IQ<<" "<<stu[i].face<<endl;
	}
}