Submission #696766

#TimeUsernameProblemLanguageResultExecution timeMemory
696766vjudge1Rice Hub (IOI11_ricehub)C++17
100 / 100
18 ms2516 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; const int maxn=1e5+5; long long pf[maxn], ki, ka, mid, idxtengah, cost, res, ans; int besthub(int R, int L, int X[], long long B) { for(int i=0; i<R; i++) { pf[i]=X[i]+(i?pf[i-1]:0); ki=0, ka=i; while(ki<=ka) { mid=(ki+ka)/2, idxtengah=(mid+i)/2; cost=(idxtengah-mid)*X[idxtengah]-((idxtengah?pf[idxtengah-1]:0)-(mid?pf[mid-1]:0)); cost+=pf[i]-pf[idxtengah]-((i-idxtengah)*X[idxtengah]); if(cost<=B) res=mid, ka=mid-1; else ki=mid+1; } ans=max(ans, i-res+1); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...