1015 德才论

题目 

#include 
#include 
#include 
using namespace std;
struct ss {
	char num[11];
	int de,cai,sum;
	int clas;//等级 
} stu[100010];
bool cmp(ss a,ss b) {
	if(a.clas != b.clas) return a.clas < b.clas;
	else if(a.sum != b.sum) return a.sum > b.sum;
	else if(a.de != b.de) return a.de > b.de;
	else return strcmp(a.num,b.num) < 0;
}
int main() {
	int N,L,H;
	scanf("%d%d%d",&N,&L,&H);
	int cnt = N;
	for(int i = 0; i < N; i++) {
		scanf("%s %d %d",&stu[i].num,&stu[i].de,&stu[i].cai);
		stu[i].sum = stu[i].de + stu[i].cai;
		if(stu[i].de < L || stu[i].cai < L) {
			stu[i].clas = 5;
			cnt--;//及格人数减少1
		} else if(stu[i].de >= H && stu[i].cai >= H) stu[i].clas = 1;
		else if(stu[i].de >= H && stu[i].cai < H) stu[i].clas = 2;
		else if(stu[i].de < H && stu[i].cai < H && stu[i].de >= stu[i].cai) stu[i].clas = 3;
		else stu[i].clas = 4;
	}
	sort(stu,stu+N,cmp);
	printf("%d\n",cnt);
	for(int i = 0; i < cnt; i++) {
		printf("%s %d %d\n",stu[i].num,stu[i].de,stu[i].cai);
	}
	return 0;
}

 

你可能感兴趣的:(练习)