제출 #879755

#제출 시각아이디문제언어결과실행 시간메모리
879755NeroZein마상시합 토너먼트 (IOI12_tournament)C++17
17 / 100
1060 ms860 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); } int mx = 0; for (int k : ppl) { mx = max(mx, (k == i ? R : (k < i ? K[k] : K[k - 1]))); } 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++; } } } int x = get(1); upd(x, -1); if (tmp > best) { best = tmp; ret = i; } } return ret; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...