#include<bits/stdc++.h>
#define f0r(i,n) for(int i = 0; i<n; i++)
#define pb push_back
#define vi vector<int>
#define ll long long int
using namespace std;
int GetBestPosition(int N, int C, int R, int *w, int *S, int *E) {
vi v;
v.pb(R);
f0r(i, N-1){
v.pb(w[i]);
}
//for(auto u : v)cout<<u<<' ';
//cout<<'\n';
int ans = -1;
int anscnt = -1;
f0r(tt, N){
vi w = v;
int curcnt = 0;
f0r(i, C){
int mx = -1;
int mxd = -1;
for(int j = S[i]; j <= E[i]; j++){
if(w[j] > mx){
mxd = j;
mx = w[j];
}
}
if(w[mxd] == R){
curcnt++;
}
int sz = w.size();
vi tmp;
f0r(j, sz){
if(j >= S[i] && j <= E[i]){
if(j == mxd)tmp.pb(w[j]);
}
else tmp.pb(w[j]);
}
w = tmp;
}
//cout<<curcnt<<'\n';
if(curcnt > anscnt){
anscnt = curcnt;
ans = tt;
}
if(tt != N-1){
swap(v[tt], v[tt+1]);
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |