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
| struct Node { int id, prob, tim, sta; };
void solve() { int n = read();
vector<Node> a(n);
unordered_map<string, int> buk; buk.reserve(n); unordered_map<int, string> Name; Name.reserve(n); set<string> winner;
int cnt = 0; for (auto &[id, prob, tim, sta] : a) { string s; cin >> s; if (!buk.count(s)) buk[s] = cnt++, Name[cnt - 1] = s; id = buk[s];
cin >> s; prob = s[0] - 'A'; cin >> tim; cin >> s; sta = s == "Accepted" ? 1 : 0; }
ranges::sort(a, [&](auto i, auto j) { return i.tim < j.tim; });
vector penalty(cnt, 0); vector ac(cnt, 0); vector pntime(cnt, vector(26, 0)); for (auto &[id, prob, tim, sta] : a) if (tim < 240) { if (pntime[id][prob] == -1) continue;
if (sta == 1) { penalty[id] += tim + pntime[id][prob]; ac[id]++; pntime[id][prob] = -1; } else { pntime[id][prob] += 20; } }
vector<int> p(cnt); ranges::iota(p, 0); ranges::sort(p, [&](int i, int j) { if (ac[i] != ac[j]) return ac[i] > ac[j]; return penalty[i] < penalty[j]; });
int best_pnt = penalty[p[0]]; int best_ac = ac[p[0]]; winner.insert(Name[p[0]]);
for (int i = 1; i < cnt; i++) { int id = p[i]; if ((ac[id] > best_ac) or (ac[id] == best_ac and penalty[id] <= best_pnt)) { winner.insert(Name[id]); } }
for (auto &[id, prob, tim, sta] : a) if (tim >= 240) { if (pntime[id][prob] == -1) continue;
penalty[id] += tim + pntime[id][prob]; ac[id]++; pntime[id][prob] = -1;
if ((ac[id] > best_ac) or (ac[id] == best_ac and penalty[id] <= best_pnt)) { winner.insert(Name[id]); } }
for (auto x : winner) { cout << x << " "; } cout << "\n"; }
|