# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
156978 | 2019-10-08T17:38:52 Z | lukameladze | 쌀 창고 (IOI11_ricehub) | C++14 | 0 ms | 0 KB |
# include<bits/stdc++.h> using namespace std; long long r,l,b,n,pos[100005],w,sum[100005],mid,shua,ans,sn,sm,ri; int main() { cin>>r>>l>>b; for (long long i=1; i<=r; i++) { cin>>pos[i]; 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; } } } cout<<ans<<endl; }