Submission #884230

#TimeUsernameProblemLanguageResultExecution timeMemory
884230tsumondaiMed (COCI22_med)C++14
10 / 50
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define mp make_pair #define foru(i, l, r) for(int i = l; i <= r; i++) #define ford(i, r, l) for(int i = r; i >= l; i--) #define __TIME (1.0 * clock() / CLOCKS_PER_SEC) typedef pair<int, int> ii; typedef pair<ii, int> iii; typedef pair<ii, ii> iiii; const int N = 500 + 5; const int oo = 1e9, mod = 1e9 + 7; int n; ii ans[N]; ii coms[N]; map<int, string> dick; void process() { cin >> n; foru(i, 1, n) { string s; int sum = 0; cin >> s; foru(i, 1, 5) { int x; cin >> x; sum += x; } //cout << sum << '\n'; coms[i] = {sum, i}; dick[i]=s; } sort(coms + 1, coms + 1 + n, greater<ii>()); foru(i, 1, n) { int cur = i; int l = i, r = i; while (abs(coms[cur].fi - coms[i].fi) < 500 && cur>=1) cur--; while (abs(coms[cur].fi - coms[i].fi) == 500 && cur>=1 && dick[coms[i].se] <= dick[coms[cur].se]) cur--; l = cur + 1; cur = i; while (abs(coms[cur].fi - coms[i].fi) < 500 && cur<=n) cur++; while (abs(coms[cur].fi - coms[i].fi) == 500 && cur<=n && dick[coms[i].se] >= dick[coms[cur].se]) cur--; r = cur - 1; ans[coms[i].se] = {l, r}; } foru(i, 1, n) cout << ans[i].fi << ' ' << ans[i].se << '\n'; return; } signed main() { cin.tie(0)->sync_with_stdio(false); //freopen(".inp", "r", stdin); //freopen(".out", "w", stdout); process(); cerr << "Time elapsed: " << __TIME << " s.\n"; return 0; } // dont stop
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...