-
Notifications
You must be signed in to change notification settings - Fork 0
/
A1062-2.cpp
59 lines (54 loc) · 1.14 KB
/
A1062-2.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: 2024-04-27 21:16:00
* modified: 2024-04-27 21:20:00
* item: Programming Ability Test
* site: 914, Harbin
*/
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
struct per {
int id;
int vir, tal, tot;
};
int main(int argc, char const *argv[]) {
int n, l, h;
cin >> n >> l >> h;
vector<per> p[4];
int cnt = n;
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) {
cnt--;
continue;
} else if (t.vir >= h && t.tal >= h) {
p[0].emplace_back(t);
} else if (t.vir >= h && t.tal < h) {
p[1].emplace_back(t);
} else if (t.vir < h && t.tal < h && t.vir >= t.tal) {
p[2].emplace_back(t);
} else {
p[3].emplace_back(t);
}
}
cout << cnt << "\n";
for (int i = 0; i < 4; i++) {
sort(p[i].begin(), p[i].end(), [](per a, per b) -> bool {
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;
}
});
for (auto it : p[i]) {
cout << it.id << " " << it.vir << " " << it.tal << "\n";
}
}
return 0;
}