# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
614007 | 2022-07-30T16:24:46 Z | chirathnirodha | Rice Hub (IOI11_ricehub) | C++17 | 0 ms | 0 KB |
#include "ricehub.h" #include<bits/stdc++.h> using namespace std; #define PB push_back typedef long long ll; int besthub(int R, int L, int X[], long long B){ int a=0;int b=0; int ans=1; ll curcos=0; while(a<R && b<R){ int pm=(a+b)/2; if(curcos<=B){ ans=max(ans,b-a+1); if(b==n-1)break; b++; curcos+=X[b]-X[pm]; } else{ a++; curcos-=X[pm]-X[b]; } int nm=(a+b)/2; curcos+=(X[nm]-X[pm])*((nm-a)-(b-pm)); } return ans; }