Submission #1103453

#TimeUsernameProblemLanguageResultExecution timeMemory
1103453overwatch9Med (COCI22_med)C++17
10 / 50
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; vector <pair <int, string>> scores; 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()); vector <int> scores2(n); for (int i = 0; i < n; i++) { scores[i].first = -scores[i].first; scores2[n-i-1] = scores[i].first; } vector <pair <int, int>> ans(n); for (int i = 0; i < n; i++) { string name = scores[i].second; int id = mp[name]; ans[id].first = n - (lower_bound(scores2.begin(), scores2.end(), scores[i].first+500) - scores2.begin() - 1); ans[id].second = n - (upper_bound(scores2.begin(), scores2.end(), scores[i].first-500) - scores2.begin() - 1) - 1; } 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...