# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
315684 | juggernaut | Jousting tournament (IOI12_tournament) | C++14 | 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<bits/stdc++.h>
//#include"grader.cpp"
#ifdef EVAL
#else
#include"grader.cpp"
#endif
using namespace std;
int a[5005],N,tree[20005],flag[20005];
int gt(int v,int l,int r,int ql,int qr){
int val=0;
for(int i=ql;i<=qr;i++)val=a[i],val);
return val;
}
void upd(int v,int l,int r,int ql,int qr,int val){
for(int i=ql;i<=qr;i++)a[i]=val;
}
int GetBestPosition(int n,int C,int R,int *K,int *s,int *e){
N=n;
vector<int>S,E,v;
for(int i=0;i<N-1;i++)K[i]=(K[i]>R);
for(int i=0;i<N;i++)v.push_back(i);
for(int i=0;i<C;i++){
S.push_back(v[s[i]]);
E.push_back(v[e[i]]);
vector<int>temp;
for(int j=0;j<v.size();j++)if(!(s[i]<j&&j<=e[i]))temp.push_back(v[j]);
v.clear();
v.insert(v.end(),temp.begin(),temp.end());
}
int mx=-1,cnt,id;
for(int pos=0;pos<N;pos++){
for(int i=0;i<pos;i++)a[i]=K[i];
a[pos]=R;
for(int i=pos+1;i<N;i++)a[i]=K[i-1];
cnt=0;
for(int i=0;i<C;i++){
int tmp=gt(1,0,N-1,S[i],E[i]);
if(tmp==0)cnt++;
else{
upd(1,0,N-1,S[i],S[i],1);
upd(1,0,N-1,E[i],E[i],1);
}
}
if(cnt>mx){
mx=cnt;
id=pos;
}
}
for(int i=0;i<C;i++)
for(int j=i+1;j<C;j++)if(S[i]<=S[j]&&E[j]<=E[i])exit(-1);
return id;
}
/*
5 3 3
1
0
2
4
1 3
0 1
0 1
*/