-
Notifications
You must be signed in to change notification settings - Fork 814
/
Copy path1137. Final Grading (25).cpp
44 lines (44 loc) · 1.2 KB
/
1137. Final Grading (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
43
44
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
struct node {
string name;
int gp, gm, gf, g;
};
bool cmp(node a, node b) {
return a.g != b.g ? a.g > b.g : a.name < b.name;
}
map<string, int> idx;
int main() {
int p, m, n, score, cnt = 1;
cin >> p >> m >> n;
vector<node> v, ans;
string s;
for (int i = 0; i < p; i++) {
cin >> s >> score;
if (score >= 200) {
v.push_back(node{s, score, -1, -1, 0});
idx[s] = cnt++;
}
}
for (int i = 0; i < m; i++) {
cin >> s >> score;
if (idx[s] != 0) v[idx[s] - 1].gm = score;
}
for (int i = 0; i < n; i++) {
cin >> s >> score;
if (idx[s] != 0) {
int temp = idx[s] - 1;
v[temp].gf = v[temp].g = score;
if (v[temp].gm > v[temp].gf) v[temp].g = int(v[temp].gm * 0.4 + v[temp].gf * 0.6 + 0.5);
}
}
for (int i = 0; i < v.size(); i++)
if (v[i].g >= 60) ans.push_back(v[i]);
sort(ans.begin(), ans.end(), cmp);
for (int i = 0; i < ans.size(); i++)
printf("%s %d %d %d %d\n", ans[i].name.c_str(), ans[i].gp, ans[i].gm, ans[i].gf, ans[i].g);
return 0;
}