-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1062 Talent and Virtue.cpp
104 lines (103 loc) · 2.12 KB
/
1062 Talent and Virtue.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# include <iostream>
# include <functional>
# include <vector>
# include <algorithm>
#include<math.h>
#include<string>
#include<cstring>
#include<iterator>
#include<iomanip>
using namespace std;
int N, L, H;
struct candidate {
int id;
int mrl;
int abt;
bool operator<(candidate c) {
if ((mrl >= H&&abt >= H) && (c.abt < H || c.mrl < H))
return true;
else if ((mrl >= H&&abt >= H) && (c.abt >= H && c.mrl >= H)) {
if (mrl + abt < c.mrl + c.abt)
return false;
else if (mrl + abt > c.mrl + c.abt)
return true;
else {
if (mrl < c.mrl)
return false;
else if (mrl > c.mrl)
return true;
else
return id < c.id;
}
}
else if ((mrl < H || abt < H) && (c.abt >= H && c.mrl >= H))
return false;
else if ((mrl >= H) && (c.mrl < H))
return true;
else if ((mrl >= H) && (c.mrl >= H)) {
if (mrl + abt < c.mrl + c.abt)
return false;
else if (mrl + abt > c.mrl + c.abt)
return true;
else {
if (mrl < c.mrl)
return false;
else if (mrl > c.mrl)
return true;
else
return id < c.id;
}
}
else if (mrl < H&&c.mrl >= H)
return false;
else if ((mrl >= abt) && (c.mrl < c.abt))
return true;
else if ((mrl >= abt) && (c.mrl >= abt)) {
if (mrl + abt < c.mrl + c.abt)
return false;
else if (mrl + abt > c.mrl + c.abt)
return true;
else {
if (mrl < c.mrl)
return false;
else if (mrl > c.mrl)
return true;
else
return id < c.id;
}
}
else if ((mrl < abt) && (c.mrl >= c.abt))
return false;
else {
if (mrl + abt < c.mrl + c.abt)
return false;
else if (mrl + abt > c.mrl + c.abt)
return true;
else {
if (mrl < c.mrl)
return false;
else if (mrl > c.mrl)
return true;
else
return id < c.id;
}
}
}
};
int main(void)
{
cin >> N >> L >> H;
vector<candidate> arr;
for (int i = 0; i < N; ++i) {
candidate tmp;
cin >> tmp.id >> tmp.mrl >> tmp.abt;
if (tmp.mrl >= L&&tmp.abt >= L)
arr.push_back(tmp);
}
sort(arr.begin(), arr.end());
cout << arr.size() << endl;
for (auto &c : arr) {
cout << c.id << ' ' << c.mrl << ' ' << c.abt << endl;
}
return 0;
}