-
Notifications
You must be signed in to change notification settings - Fork 0
/
1015.cpp
80 lines (75 loc) · 2.08 KB
/
1015.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
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
/*
德分 >= H && 才分 >= H "才德全尽" 按德才总分从高到低
才分 < H && 德分 >= H "德胜才" 按总分排序,在 "才德全尽"之后排序
才分 < H && 德分 < H && 德分 >= 才分 "才德兼亡" 按总分排序,在"德胜才"之后
德分 >= L && 才分 >= L 总分,最后排序
*/
class stu
{
public:
int moral_score;
int talent_score;
string id;
int sclass;
};
int N, L, H;
int main()
{
vector<stu> v;
cin >> N >> L >> H;
for (int i = 0; i < N; i++)
{
stu s;
cin >> s.id;
cin >> s.moral_score;
cin >> s.talent_score;
if (s.moral_score >= L && s.talent_score >= L)
{
if (s.moral_score >= H && s.talent_score >= H)
{
s.sclass = 1;
}
else if (s.talent_score < H && s.moral_score >= H)
{
s.sclass = 2;
}
else if (s.talent_score < H && s.moral_score < H && s.moral_score >= s.talent_score)
{
s.sclass = 3;
}
else
{
s.sclass = 4;
}
v.push_back(s);
}
}
sort(v.begin(), v.end(), [](stu s1, stu s2) -> bool
{
if (s1.sclass != s2.sclass)
return s1.sclass < s2.sclass;
else if (s1.moral_score + s1.talent_score != s2.moral_score + s2.talent_score)
{
return s1.moral_score + s1.talent_score > s2.moral_score + s2.talent_score;
}
else if (s1.moral_score != s2.moral_score)
{
return s1.moral_score > s2.moral_score;
}
else
{
return s1.id < s2.id;
}
});
cout << v.size() << endl;
for(int i = 0; i < v.size(); i++) {
cout << v[i].id << " " << v[i].moral_score << " " << v[i].talent_score;
if(i != v.size() - 1) {
cout << endl;
}
}
}