codeforces round 262

Правка en1, от vsanjay_nitdgp, 2015-06-22 17:24:23

http://mirror.codeforces.com/contest/460/problem/C

can any one pls explain how to do this problem through binary search.

include

include <stdio.h>

using namespace std; long long i,n,k,m[200010],w,l,r,z,a[200010],kol,sum,p; int main(){ //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); cin>>n>>k>>w; for (i=0;i<n;i++) cin>>m[i]; l=1; r=10; while (l<=r){ z=(l+r)/2; kol=0; sum=0; for(p=0;p<10;p++) a[p]=0; for ( i=0;i<n && kol<=k;i++){ sum=sum+a[i]; if (m[i]+sum<z){ kol=kol+z-(m[i]+sum); a[i+w]-=z-(m[i]+sum); sum=z-m[i]; } } if (kol<=k) l=z+1; else r=z-1;

}
cout<<r;
return 0;

} here is one of the codes and i couldnt understand any thing at all.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский vsanjay_nitdgp 2015-06-22 17:24:23 793 Initial revision (published)