Cod sursa(job #346303)

Utilizator MKLOLDragos Ristache MKLOL Data 7 septembrie 2009 14:28:25
Problema Subsecventa de suma maxima Scor 80
Compilator cpp Status done
Runda Arhiva educationala Marime 0.33 kb
#include<stdio.h>
int S,ifin,jfin,w=1,max=-40000,N,o=1,x;
int main()
{
freopen("ssm.in","r",stdin);
freopen("ssm.out","w",stdout);
scanf("%d",&N);
while(o<=N)
{
scanf("%d",&x);

S=S+x;
if(S>max)
{
max=S;
ifin=w;
jfin=o;
}
if(S<0)
{
S=0;
w=o+1;
}
++o;
}



printf("%d %d %d",max,ifin,jfin);

return 0;
}