Cod sursa(job #627010)
| Utilizator | Data | 28 octombrie 2011 19:54:14 | |
|---|---|---|---|
| Problema | Transport | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.64 kb |
#include<stdio.h>
#define N 16001
long a[N],n,i,k,s[N],x,c,l,t,y,m;
int main()
{freopen("transport.in","r",stdin);
freopen("transport.out","w",stdout);
scanf("%ld%ld",&n,&k);
for(i=1;i<=n;i++)
{scanf("%ld",&a[i]),s[i]=s[i-1]+a[i];
if(m<a[i])
m=a[i];}
c=m+1;
while(1)
{for(i=1,t=x=0;i<=n;i++)
if(s[i]-s[t]>c)
t=i-2,x++;
if(x==k)
y=1,c--;
if(!y)
if(x<k)
c--;
else
c++;
else
if(x!=k)
break;}
printf("%ld",c+1);
return 0;}
