Submission #879753

#TimeUsernameProblemLanguageResultExecution timeMemory
879753NeroZeinJousting tournament (IOI12_tournament)C++17
0 / 100
1053 ms1248 KiB
#include "bits/stdc++.h" using namespace std; const int M = 5003; int tree[M]; void upd(int i, int v) { i++; while (i < M) { tree[i] += v; i += i & -i; } } int get(int v) { int pos = 0, sum = 0; for (int i = 12; i >= 0; --i) { if (pos + (1 << i) < M && sum + tree[pos + (1 << i)] < v) { pos += 1 << i; sum += tree[pos]; } } return pos; } int GetBestPosition(int N, int C, int R, int *K, int *S, int *E) { int ret = 0, best = 0; for (int i = 0; i < N; ++i) { for (int j = 0; j < N; ++j) { upd(j, 1); } int tmp = 0; for (int j = 0; j < C; ++j) { int ql = S[j], qr = E[j]; vector<int> ppl; for (int k = 0; k < qr - ql + 1; ++k) { int f = get(ql + 1 + k); ppl.push_back(f); //cout << "F: " << f << '\n'; } int mx = 0; for (int k : ppl) { mx = max(mx, (k == i ? R : (k < i ? K[k] : K[k - 1]))); } //cout << "J, ppl: " << j << '\n'; //for (int k : ppl) cout << k << ' '; //cout << '\n'; for (int k : ppl) { int val = (k == i ? R : (k < i ? K[k] : K[k - 1])); if (val != mx) { upd(k, -1); } else if (k == i) { tmp++; } } } if (tmp > best) { //cout << "TMP: " << tmp << '\n'; best = tmp; ret = i; } } return ret; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...