Submission #401985

#TimeUsernameProblemLanguageResultExecution timeMemory
401985JasiekstrzJousting tournament (IOI12_tournament)C++17
0 / 100
878 ms1972 KiB
#include<bits/stdc++.h> #define fi first #define se second using namespace std; const int NN=1e5; const int L=17; int bg[NN+10]; int en[NN+10]; int d[NN+10]; int mx[L+2][2][NN+10]; void build_rmq(int N,int *K) { for(int rot:{1,0}) { for(int i=0;i<N-1;i++) { mx[0][rot][i]=K[i]; for(int j=1;j<=L;j++) { if(i-(1<<(j-1))<0) mx[j][rot][i]=mx[j-1][rot][i]; else mx[j][rot][i]=max(mx[j-1][rot][i],mx[j-1][rot][i-(1<<(j-1))]); } } reverse(K,K+N-1); for(int j=0;j<=L;j++) { reverse(mx[j][0],mx[j][0]+N-1); reverse(mx[j][1],mx[j][1]+N-1); } } return; } int get_max(int l,int r) { int lg=__lg(r-l+1); return max(mx[lg][0][l],mx[lg][1][r]); } void add_interval(int l,int r,int R) { if(l==r || get_max(l,r-1)<R) { d[l]++; d[r+1]--; } return; } int GetBestPosition(int N,int C,int R,int *K,int *S,int *E) { for(int i=0;i<N;i++) bg[i]=en[i]=i; int n=N; for(int i=0;i<C;i++) { add_interval(bg[S[i]],en[E[i]],R); en[S[i]]=en[E[i]]; n=n-E[i]+S[i]; for(int j=S[i]+1;j<n;j++) { bg[j]=bg[j-S[i]+E[i]]; en[j]=en[j-S[i]+E[i]]; } } int ans=0,bst=0; int curr=0; for(int i=0;i<N;i++) { curr+=d[i]; if(curr>ans) { ans=curr; bst=i; } } return bst; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...