Cod sursa(job #284703)
Utilizator | Data | 21 martie 2009 21:49:35 | |
---|---|---|---|
Problema | Subsecventa de suma maxima | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.89 kb |
#include<stdio.h>
long long i,n,j;
int main()
{
freopen("ssm.in","r",stdin);
freopen("ssm.out","w",stdout);
scanf("%lld",&n);
long long ant,prim,curent,max,pzi=1,pzj=1;
scanf("%lld",&prim);
ant=prim;curent=prim;
max=prim;
for(i=2;i<=n;i++)
{
scanf("%lld",&prim);
curent=prim;
if(curent+ant>=curent)
curent=curent+ant;
else j=i;
if(curent>max)
{max=curent;
pzi=i;
pzj=j;
}
ant=curent;
}
printf("%lld %lld %lld\n",max,pzj,pzi);
return 0;
}