Cod sursa(job #280353)
Utilizator | Alexandru-Iancu Caragicu Bit_Master | Data | 13 martie 2009 12:35:17 |
---|---|---|---|
Problema | Subsecventa de suma maxima | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.47 kb |
#include <stdio.h>
void calcul()
{
long n,x,sc=0,smax=-1000000000,stc=1,drc,stmax,drmax;
scanf ("%ld",&n);
for (drc = 1; drc <= n; ++drc)
{
scanf ("%ld",&x);
sc += x;
if (sc > smax)
{
smax = sc;
stmax = stc;
drmax = drc;
}
if (sc < 0)
{
sc = 0;
stc = drc + 1;
}
}
printf("%ld%ld%ld",smax,stmax,drmax);
}
int main()
{
freopen ("ssm.in","r",stdin);
freopen ("ssm.out","w",stdout);
calcul();
return 0;
}