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: 83ms
Memory: 3020kB
Author: CT12812031281
In contest: 1281

#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<map>
#include<set>
#include<queue>
#include<vector>
using namespace std;
int n,l,h,x,y;
char s[20];
//double p,q;
struct Arr1{
	char name[20];
	int zhi,yan,sum;
}arr1[10010];
struct Arr2{
	char name[20];
	int zhi,yan,sum;
}arr2[10010];
struct Arr3{
	char name[20];
	int zhi,yan,sum;
}arr3[10010];
struct Arr4{
	char name[20];
	int zhi,yan,sum;
}arr4[10010];
int cmp1(const Arr1 &x, const Arr1 &y){
	if(x.sum==y.sum){
		if(x.zhi==y.zhi){
			if(strcmp(x.name,y.name)<0) return 1;
		}return x.zhi>y.zhi;
	}return x.sum>y.sum;
}
int cmp2(const Arr2 &x, const Arr2 &y){
	if(x.sum==y.sum){
		if(x.zhi==y.zhi){
			if(strcmp(x.name,y.name)<0) return 1;
		}return x.zhi>y.zhi;
	}return x.sum>y.sum;
}
int cmp3(const Arr3 &x, const Arr3 &y){
	if(x.sum==y.sum){
		if(x.zhi==y.zhi){
			if(strcmp(x.name,y.name)<0) return 1;
		}return x.zhi>y.zhi;
	}return x.sum>y.sum;
}
int cmp4(const Arr4 &x, const Arr4 &y){
	if(x.sum==y.sum){
		if(x.zhi==y.zhi){
			if(strcmp(x.name,y.name)<0) return 1;
		}return x.zhi>y.zhi;
	}return x.sum>y.sum;
}
int main()
{
	scanf("%d %d %d",&n,&l,&h);int k1=0,k2=0,k3=0,k4=0;
	for(int i=1;i<=n;i++){
		scanf("%s %d %d",s,&x,&y);
		if(x>=l&&y>=l){
			if(x>=h&&y>=h){
				strcpy(arr1[++k1].name,s),arr1[k1].zhi=x,arr1[k1].yan=y;
				arr1[k1].sum=arr1[k1].zhi+arr1[k1].yan;
			}else if(x>=h&&y<h){
				strcpy(arr2[++k2].name,s),arr2[k2].zhi=x,arr2[k2].yan=y;
				arr2[k2].sum=arr2[k2].zhi+arr2[k2].yan;
			}else if(x<h&&y<h&&x>=y){
				strcpy(arr3[++k3].name,s),arr3[k3].zhi=x,arr3[k3].yan=y;
				arr3[k3].sum=arr3[k3].zhi+arr3[k3].yan;
			}else{
				strcpy(arr4[++k4].name,s),arr4[k4].zhi=x,arr4[k4].yan=y;
				arr4[k4].sum=arr4[k4].zhi+arr4[k4].yan;
			}
		}
		
	}
	printf("%d\n",k1+k2+k3+k4);
	sort(arr1+1,arr1+1+k1,cmp1);
	sort(arr2+1,arr2+1+k2,cmp2);
	sort(arr3+1,arr3+1+k3,cmp3);
	sort(arr4+1,arr4+1+k4,cmp4);
	for(int i=1;i<=k1;i++){
		printf("%s %d %d\n",arr1[i].name,arr1[i].zhi,arr1[i].yan);
	}
	for(int i=1;i<=k2;i++){
		printf("%s %d %d\n",arr2[i].name,arr2[i].zhi,arr2[i].yan);
	}
	for(int i=1;i<=k3;i++){
		printf("%s %d %d\n",arr3[i].name,arr3[i].zhi,arr3[i].yan);
	}
	for(int i=1;i<=k4;i++){
		printf("%s %d %d\n",arr4[i].name,arr4[i].zhi,arr4[i].yan);
	}
}