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 <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <vector>
#include <algorithm>
#include <iostream>
//#include "tournament.h"
using namespace std;
int GetBestPosition(int N, int C, int R, int K[], int S[], int E[]){
vector<int> arr(N-1);
int id = 0, ms = 0;
for(int i = 0; i < N-1; i ++){
arr[i] = K[i];
}
for(int i = 0; i < N; i ++){
vector<int> crr = arr;
vector<pair<int, int>> brr;
int score = 0;
crr.insert(crr.begin()+i, R);
for(int j = 0; j < N; j ++){
brr.push_back({crr[j], j+1});
}
for(int j = 0; j < C; j ++){
int s = S[j], e = E[j];
int p = 0, pos = 0;
while(p < s){
pos = brr[pos].second;
p++;
}
int sp = pos;
int maxi = 0;
while(p <= e){
maxi = max(maxi, brr[pos].first);
pos = brr[pos].second;
p++;
}
brr[sp] = {maxi, pos};
if(maxi == R){
score ++;
}
}
if(score > ms){
ms = score;
id = i;
}
}
return id;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |