Submission #1056740

#TimeUsernameProblemLanguageResultExecution timeMemory
1056740PikachudoraEHERice Hub (IOI11_ricehub)C++14
68 / 100
17 ms3244 KiB
#include "ricehub.h" #include<bits/stdc++.h> using namespace std; long long idx[100005];int n;long long qs[100005];int b; bool chk(int a){ long long mi=LLONG_MAX; for(int l=1;l<=n-a+1;l++){ int r =l+a-1;int m=(l+r)/2; mi=min(mi,(m-l+1)*idx[m]-qs[m]+qs[l-1]-(r-m)*(idx[m])+qs[r]-qs[m]); } return mi<=b; } int besthub(int R, int L, int X[], long long B){ int l=0;int r=R;n=R;b=B; for(int i=0;i<R;i++){idx[i+1]=X[i];qs[i+1]=qs[i]+idx[i+1];} while(l<r){ int mid = (l+r+1)/2; if(chk(mid)){ l=mid; } else{ r =mid-1; } } return l; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...