# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
157732 | 2019-10-12T18:53:37 Z | lukameladze | Rice Hub (IOI11_ricehub) | C++14 | 0 ms | 0 KB |
# include<bits/stdc++.h> using namespace std; long long n,pos[100005],w,sum[100005],mid,shua,ans,sn,sm,ri; int besthub(int r,int l,long long x[],int b) { //cin>>r>>l>>b; for (long long i=1; i<=r; i++) { pos[i]=x[i-1]; w+=pos[i]; sum[i]=w; } l=1; ri=r; while (l<=ri) { mid=(l+ri)/2; for (long long i=1; i<=ri-mid+1; i++) { shua=(i+i+mid)/2; sn=sum[shua-1]-sum[i-1]; sm=sum[i+mid-1]-sum[shua]; if ((pos[shua]*(shua-i)-sn)+sm-(pos[shua]*(i+mid-1-shua))<=b) { ans=mid; l=mid+1; } else { ri=mid-1; } } } return ans; }