Cod sursa(job #260920)
Utilizator | Data | 17 februarie 2009 18:38:47 | |
---|---|---|---|
Problema | Subsecventa de suma maxima | Scor | Ascuns |
Compilator | fpc | Status | done |
Runda | Marime | 0.73 kb |
var n, s, nr, start, stop, d, max, i :longint;
begin
assign(input, 'ssm.in'); reset(input);
assign(output, 'ssm.out'); rewrite(output);
readln(n);
s := 0; max := -2000000000;
d := 1;
for i := 1 to n do begin
read(nr);
if (s + nr < nr) then begin
if (s > max) then begin
start := d;
stop := i - 1;
max := s;
end;
s := nr; d := i;
end
else
s := s + nr;
if (s > max) then begin
start := d;
stop := i;
max := s;
end;
end;
writeln(max, ' ', start, ' ', stop);
end.