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: 104ms
Memory: 8012kB
Author: CT12811551281
In contest: 1281

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
struct my
{
	int number;
	int iq;
	int look;
	int score;
}sz1[100010],sz2[100010],sz3[100010],sz4[100010];

bool comp(my a,my b)
{
	if(a.score==b.score)
	{	if(a.iq==b.iq)
			return a.number<b.number;
		else
			return a.iq>b.iq;
	}
	else 
	return a.score>b.score;
}

int main()
{
	int N,L,H;int M=0;
	cin>>N>>L>>H;int sum1=0,sum2=0,sum3=0,sum4=0;
	for(int i=1;i<=N;i++)
	{
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		if(b>=L&&c>=L) M++;
		if(b>=H&&c>=H) 
		{
			sum1++;
			sz1[sum1].number=a;
			sz1[sum1].iq=b;
			sz1[sum1].look=c;
			sz1[sum1].score=b+c;
		}
		else if(b>=H&&c<H)
		{
			sum2++;
			sz2[sum2].number=a;
			sz2[sum2].iq=b;
			sz2[sum2].look=c;
			sz2[sum2].score=b+c;
		}
		else if(b<H&&c<H&&b>=c)
		{
			sum3++;
			sz3[sum3].number=a;
			sz3[sum3].iq=b;
			sz3[sum3].look=c;
			sz3[sum3].score=b+c;
		}
		else
		{
			sum4++;
			sz4[sum4].number=a;
			sz4[sum4].iq=b;
			sz4[sum4].look=c;
			sz4[sum4].score=b+c;
		}
	}
	sort(sz1+1,sz1+1+sum1,comp);
	sort(sz2+1,sz2+1+sum2,comp);
	sort(sz3+1,sz3+1+sum3,comp);
	sort(sz4+1,sz4+1+sum4,comp);
	cout<<M<<endl;
	int flag=0;
	for(int i=1;i<=sum1;i++)
	{
		if(i+flag>M)
			break;
		if(sz1[i].iq<L||sz1[i].look<L)
		{
			flag--;
			continue;
		}
		printf("%08d %d %d\n",sz1[i].number,sz1[i].iq,sz1[i].look);
	}
	for(int i=1;i<=sum2;i++)
	{
		if(i+sum1+flag>M)
			break;
		if(sz2[i].iq<L||sz2[i].look<L)
		{
			flag--;
			continue;
		}
		printf("%08d %d %d\n",sz2[i].number,sz2[i].iq,sz2[i].look);
	}
	for(int i=1;i<=sum3;i++)
	{	
		if(i+sum1+sum2+flag>M)
			break;
		if(sz3[i].iq<L||sz3[i].look<L)
		{
			flag--;
			continue;
		}
		printf("%08d %d %d\n",sz3[i].number,sz3[i].iq,sz3[i].look);
	}
	for(int i=1;i<=sum4;i++)
	{
		if(i+sum1+sum2+sum3+flag>M)
			break;
		if(sz4[i].iq<L||sz4[i].look<L)
		{
			flag--;
			continue;
		}
		printf("%08d %d %d\n",sz4[i].number,sz4[i].iq,sz4[i].look);
	}
	return 0;
}