Submission #696762

#TimeUsernameProblemLanguageResultExecution timeMemory
696762vjudge1Rice Hub (IOI11_ricehub)C++17
0 / 100
3 ms596 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*X[idxtengah]-(idxtengah?pf[idxtengah-1]:0); cost+=pf[mid]-(idxtengah?pf[idxtengah-1]:0)-((mid-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...