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: 651ms
Memory: 3096kB
Author: CT12810381281
In contest: 1281

#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<deque>
#include<map>
#include<algorithm>
#include<cctype>
using namespace std;
map<string, int> x;
deque<pair<string, int>> r;
struct m {
	string name;
	int zs;
	int yz;
	int num;
	int hh;
	int grade;
	int ll;
};
deque<m>aa;
bool cmp3(m x, m y) {
	return x.name < y.name;
}
bool cmp2(m x, m y) {
	if(x.zs == y.zs)
		return cmp3(x, y);
	return x.zs > y.zs;
}
bool cmp1(m x, m y) {
	if(x.num == y.num)
		return cmp2(x, y);
	return x.num > y.num;
}
bool cmp(m x, m y) {
	if(x.grade == y.grade)
		return cmp1(x, y);
	return x.grade < y.grade;
}

int main() {
	int n, l, h;
	cin >> n >> l >> h;
	m a;
	a.hh = h;
	a.ll = l;
	while(n--) {
		cin >> a.name >> a.zs >> a.yz;
		a.num = a.zs + a.yz;
		if(a.zs >= a.hh && a.yz >= a.hh)
			a.grade = 1;
		else if(a.zs >= a.hh && a.yz >= a.ll)
			a.grade = 2;
		else if(a.yz >= a.ll && a.zs >= a.ll && a.zs >= a.yz)
			a.grade = 3;
		else if(a.yz >= a.ll && a.zs >= a.ll)
			a.grade = 4;
		else 
			a.grade = 5;
		if(a.grade < 5)
			aa.push_back(a);
	}
	sort(aa.begin(), aa.end(), cmp);
	cout << aa.size() << endl;
	for(int i = 0; i < aa.size(); i++) {
		cout << aa[i].name << " " << aa[i].zs << " " << aa[i].yz;
		if(i != aa.size() - 1)
			cout << endl;
	}
	return 0;
}