德与才
作者:
漆黑泽克斯原始型二
,
2023-04-16 13:19:12
,
所有人可见
,
阅读 201
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct Student {
int id, virtue, talent, total, type;
};
bool cmp(Student a, Student b) {
if (a.type != b.type) {
return a.type < b.type;
} else if (a.total != b.total) {
return a.total > b.total;
} else if (a.virtue != b.virtue) {
return a.virtue > b.virtue;
} else {
return a.id < b.id;
}
}
int main() {
int n, l, h;
cin >> n >> l >> h;
vector<Student> students;
for (int i = 0; i < n; i++) {
int id, virtue, talent;
cin >> id >> virtue >> talent;
int total = virtue + talent;
int type = 0;
if (virtue >= h && talent >= h) {
type = 1;
} else if (virtue >= h && talent >= l) {
type = 2;
} else if (virtue >= talent && virtue >= l && talent >= l) {
type = 3;
} else if (virtue >= l && talent >= l) {
type = 4;
}
if (type != 0) {
students.push_back({id, virtue, talent, total, type});
}
}
sort(students.begin(), students.end(), cmp);
int m = students.size();
cout << m << endl;
for (int i = 0; i < m; i++) {
cout << students[i].id << " " << students[i].virtue << " " << students[i].talent << endl;
}
return 0;
}