Submission #1137360

#TimeUsernameProblemLanguageResultExecution timeMemory
1137360jackofall718Med (COCI22_med)C++20
0 / 50
1 ms320 KiB
#include <bits/stdc++.h> #define ll long long int #define endl '\n' using namespace std; // Custom comparator for sorting by score descending, then name lexicographically if scores are equal bool cmp(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() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<pair<int, string>> m(n); for (int i = 0; i < n; ++i) { string name; cin >> name; int sum = 0, score; for (int j = 0; j < 5; ++j) { cin >> score; sum += score; } m[i] = {sum, name}; } for (int i = 0; i < n; ++i) { auto x = m; // Copy of original vector to manipulate scores x[i].first += 500; // Simulate the best scenario sort(x.begin(), x.end(), cmp); auto it = find_if(x.begin(), x.end(), [&](const pair<int, string>& elem) { return elem == m[i]; }); cout << (it - x.begin() + 1) << " "; auto y = m; // Another copy for the worst scenario y[i].first -= 1000; // Simulate the worst scenario sort(y.begin(), y.end(), cmp); it = find_if(y.begin(), y.end(), [&](const pair<int, string>& elem) { return elem == m[i]; }); cout << (it - y.begin() + 1) << endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...