-
Notifications
You must be signed in to change notification settings - Fork 814
/
Copy path1062. Talent and Virtue (25).cpp
42 lines (42 loc) · 1.19 KB
/
1062. Talent and Virtue (25).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
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
struct node {
int num, de, cai;
};
int cmp(struct node a, struct node b) {
if ((a.de + a.cai) != (b.de + b.cai))
return (a.de + a.cai) > (b.de + b.cai);
else if (a.de != b.de)
return a.de > b.de;
else
return a.num < b.num;
}
int main() {
int n, low, high;
scanf("%d %d %d", &n, &low, &high);
vector<node> v[4];
node temp;
int total = n;
for (int i = 0; i < n; i++) {
scanf("%d %d %d", &temp.num, &temp.de, &temp.cai);
if (temp.de < low || temp.cai < low)
total--;
else if (temp.de >= high && temp.cai >= high)
v[0].push_back(temp);
else if (temp.de >= high && temp.cai < high)
v[1].push_back(temp);
else if (temp.de < high && temp.cai < high && temp.de >= temp.cai)
v[2].push_back(temp);
else
v[3].push_back(temp);
}
printf("%d\n", total);
for (int i = 0; i < 4; i++) {
sort(v[i].begin(), v[i].end(), cmp);
for (int j = 0; j < v[i].size(); j++)
printf("%d %d %d\n", v[i][j].num, v[i][j].de, v[i][j].cai);
}
return 0;
}