-
Notifications
You must be signed in to change notification settings - Fork 2
/
1137.cpp
43 lines (41 loc) · 1.1 KB
/
1137.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
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
struct Student {
string name;
int assign = -1, mid = -1, final = -1, total = -1;
};
int main() {
int n, m, k;
cin >> n >> m >> k;
int score;
string name;
map<string, Student> students;
while (n--) {
cin >> name >> score;
students[name].assign = score;
}
while (m--) {
cin >> name >> score;
students[name].mid = score;
}
while (k--) {
cin >> name >> score;
students[name].final = score;
}
vector<Student> ans;
for (auto entry : students) {
Student s = entry.second;
s.name = entry.first;
s.total = ((s.mid > s.final ? s.mid * 0.4 + s.final * 0.6 : s.final) + 0.5);
if (s.assign >= 200 && s.total >= 60) ans.push_back(s);
}
sort(ans.begin(), ans.end(), [](Student a, Student b) {
return a.total != b.total ? a.total > b.total : a.name < b.name;
});
for (auto s : ans)
printf("%s %d %d %d %d\n", s.name.c_str(), s.assign, s.mid, s.final, s.total);
return 0;
}