-
Notifications
You must be signed in to change notification settings - Fork 0
/
A1062-1.cpp
59 lines (54 loc) · 1.12 KB
/
A1062-1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
* author: zhouyuhao
* created: 2023-03-23 13:05:34
* modified: 2023-03-23 13:26:51
* item: Programming Ability Test
* site: Yuting
*/
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
struct per {
int id;
int vir, tal, tot;
int flag;
};
int main(int argc, char const *argv[]) {
int n, l, h;
cin >> n >> l >> h;
vector<per> p;
for (int i = 0; i < n; i++) {
per t;
cin >> t.id >> t.vir >> t.tal;
t.tot = t.vir + t.tal;
if (t.vir < l || t.tal < l) {
continue;
} else if (t.vir >= h && t.tal >= h) {
t.flag = 1;
} else if (t.vir >= h && t.tal < h) {
t.flag = 2;
} else if (t.vir < h && t.tal < h && t.vir >= t.tal) {
t.flag = 3;
} else {
t.flag = 4;
}
p.emplace_back(t);
}
sort(p.begin(), p.end(), [](per a, per b) -> bool {
if (a.flag != b.flag) {
return a.flag < b.flag;
} else if (a.tot != b.tot) {
return a.tot > b.tot;
} else if (a.vir != b.vir) {
return a.vir > b.vir;
} else {
return a.id < b.id;
}
});
cout << p.size() << "\n";
for (auto it : p) {
cout << it.id << " " << it.vir << " " << it.tal << "\n";
}
return 0;
}