Submission #644381

#TimeUsernameProblemLanguageResultExecution timeMemory
644381IwanttobreakfreeMed (COCI22_med)C++17
50 / 50
1 ms324 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int n; cin >> n; vector<pair<pair<int,string>,int>> bee (n); for (int i = 0; i < n; ++i) { cin >> bee[i].first.second; bee[i].second = i; for (int j = 0; j < 5; ++j){ int x; cin >> x; bee[i].first.first -= x; } } sort (bee.begin(),bee.end()); vector<pair<int,int>> ans (n); for (int i = 0; i < n; ++i) { //cout << bee[i].first.first << '\n'; int b = i, w = i; for (int j = 0; j < i; ++j) { if (-bee[i].first.first+500 > -bee[j].first.first) { b = j; break; } if (-bee[i].first.first+500 == -bee[j].first.first and bee[i].first.second < bee[j].first.second) { b = j; break; } } for (int j = i+1; j < n; ++j) { if (-bee[i].first.first < -bee[j].first.first+500) { w = j; } if (-bee[i].first.first-500 == -bee[j].first.first and bee[i].first.second > bee[j].first.second) { w = j; } } ans[bee[i].second] = {b+1,w+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...