Submission #1087066

#TimeUsernameProblemLanguageResultExecution timeMemory
1087066toast12Med (COCI22_med)C++14
10 / 50
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; bool compare(pair<int, string> a, pair<int, string> b) { return (a.first == b.first ? a.second < b.second : a.first > b.first); } int main() { int n; cin >> n; vector<pair<int, string>> people(n); for (int i = 0; i < n; i++) { cin >> people[i].second; for (int j = 0; j < 5; j++) { int x; cin >> x; people[i].first += x; } } vector<pair<int, string>> temp = people; sort(people.begin(), people.end(), compare); vector<pair<int, int>> ans(n); for (int i = 0; i < n; i++) { int a = n; for (int j = 0; j < n; j++) { if (j == i) continue; if (people[j].first < people[i].first+500) { if (j < i) a = j+1; else a = j; break; } } int b = a; for (int j = n-1; j >= 0; j--) { if (j == i) continue; if (people[j].first+500 > people[i].first) { if (j < i) b = j+2; else b = j+1; break; } } ans[i] = {a, b}; } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (temp[i].second == people[j].second) { cout << ans[j].first << ' ' << ans[j].second << '\n'; break; } } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...