Cod sursa(job #923801)
| Utilizator | Data | 23 martie 2013 20:55:09 | |
|---|---|---|---|
| Problema | Transport | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.48 kb |
#include<cstdio>
int s[16010];
using namespace std;
int main()
{
freopen("transport.in","r",stdin);
freopen("transport.out","w",stdout);
int n,k,i,j,max=0,p,v,last;
scanf("%d%d",&n,&k);
for(i=1;i<=n;i++)
scanf("%d",&s[i]);
max=s[1];
last=1;
for(i=2;i<=k;i++)
{
p=0;
for(j=last;j<=i;j++)
p=p+s[j];
last=j-1;
if(p>max)
max=p;
}
printf("%d\n",max);
return 0;
}
