Submission #952475

#TimeUsernameProblemLanguageResultExecution timeMemory
952475adkjtRice Hub (IOI11_ricehub)C++14
68 / 100
12 ms2652 KiB
#include "ricehub.h" #include<bits/stdc++.h> using namespace std; #define ll long long int qs[111111]; int besthub(int R, int L, int X[], long long B) { for(int i=R;i>0;i--) X[i]=X[i-1]; for(int i=1;i<=R;i++) { qs[i]=qs[i-1]+X[i]; } int mx=0,l=1,r=1; while(l<=R&&r<=R) { int mid=(l+r)/2; ll cost=qs[r]-qs[mid]-((1ll)*X[mid]*(r-mid))+((1ll)*X[mid]*(mid-l))-qs[mid-1]+qs[l-1]; //cout<<r<<' '<<l<<' '<<r-l+1<<' '<<cost<<'\n'; if(cost<=B) mx=max(mx,r-l+1),r++; else l++; } return mx; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...