Cod sursa(job #695128)
Utilizator | DamianRazvan RazvanDamian | Data | 28 februarie 2012 10:37:41 |
---|---|---|---|
Problema | Subsecventa de suma maxima | Scor | 100 |
Compilator | fpc | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
var smax,sc,poz,sf,i,n,inceput,x:longint; f:text;
begin
assign(f,'ssm.in'); reset(f);
readln(f,n);
read(f,smax);
sc:=smax;
poz:=1;
inceput:=1;
sf:=1;
for i:=2 to n do begin read(f,x);
if sc<0 then begin
sc:=x;
poz:=i;
end else sc:=sc+x;
if smax<sc then begin
smax:=sc;
inceput:=poz;
sf:=i;
end;
end;
close(f);
assign(f,'ssm.out'); rewrite(f);
write(f,smax,' ',inceput,' ',sf); close(f);
end.