# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
830162 | Liudas | Jousting tournament (IOI12_tournament) | C++17 | 0 ms | 0 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 <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <vector>
#include <algorithm>
#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> brr = arr;
int score = 0;
brr.insert(brr.begin()+i, R);
for(int j = 0; j < C; j ++){
vector<int> crr;
int s = S[j], e = E[j];
for(int k = 0; k < s; k ++){
crr.push_back(brr[k]);
}
for(int k = e + 1; k < brr.size(); k ++){
crr.push_back(brr[k]);
}
int maxi = *max_element(brr.begin() + s, brr.begin() + e + 1);
if(maxi == R)score++;
crr.insert(crr.begin() + s, maxi);
swap(brr, crr);
}
if(score > ms){
ms = score;
id = i;
}
}
return id;
}