# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
532600 | cig32 | Jousting tournament (IOI12_tournament) | C++17 | 1093 ms | 1560 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "bits/stdc++.h"
using namespace std;
const int MAXN = 1e5 + 10;
int st[17][MAXN];
int query(int l, int r) {
int k = 32 - __builtin_clz(r-l+1) - 1; return max(st[k][l], st[k][r - (1<<k) + 1]);
}
int GetBestPosition(int N, int C, int R, int *K, int *S, int *E) {
int opt_cnt = 0, opt_id = -1;
for(int P=0; P<N; P++) {
vector<int> now;
for(int j=0; j<P; j++) now.push_back(K[j]);
now.push_back(R);
for(int j=P; j<N; j++) now.push_back(K[j]);
int res = 0;
for(int i=0; i<C; i++) {
int mx = 0;
for(int j=S[i]; j<=E[i]; j++) {
mx = max(mx, now[j]);
}
vector<int> rep;
for(int j=0; j<S[i]; j++) rep.push_back(now[j]);
rep.push_back(mx);
for(int j=E[i]+1; j<now.size(); j++) rep.push_back(now[j]);
now = rep;
if(mx == R) res++;
}
if(res > opt_cnt) {
opt_cnt = res, opt_id = P;
}
}
return opt_id;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |