Submission #1103469

#TimeUsernameProblemLanguageResultExecution timeMemory
1103469overwatch9Med (COCI22_med)C++17
50 / 50
3 ms340 KiB
#include <bits/stdc++.h> using namespace std; vector <pair <int, string>> scores; bool comp(const pair <int, string> &a, const pair <int, string> &b) { if (a.first == b.first) return a.second < b.second; return a.first > b.first; } int main() { int n; cin >> n; map <string, int> mp; scores.resize(n); for (int i = 0; i < n; i++) { string s; cin >> s; scores[i].second = s; mp[s] = i; for (int j = 0; j < 5; j++) { int x; cin >> x; scores[i].first -= x; } } sort(scores.begin(), scores.end()); multiset <pair <int, string>, bool (*)(const pair <int, string> &, const pair <int, string> &)> scores2(comp); for (int i = 0; i < n; i++) { scores[i].first = -scores[i].first; scores2.insert(scores[i]); } vector <pair <int, int>> ans(n); for (int i = 0; i < n; i++) { string name = scores[i].second; int id = mp[name]; pair <int, string> tp = scores[i]; scores2.erase(tp); tp.first += 500; scores2.insert(tp); auto it = scores2.begin(); for (int j = 0; j < n; j++) { if (it->second == name) { ans[id].first = j+1; break; } it++; } scores2.erase(tp); tp.first -= 1000; scores2.insert(tp); it = scores2.begin(); for (int j = 0; j < n; j++) { if (it->second == name) { ans[id].second = j+1; break; } it++; } scores2.erase(tp); tp.first += 500; scores2.insert(tp); } for (int i = 0; i < n; i++) cout << ans[i].first << ' ' << ans[i].second << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...