Pagini recente » Cod sursa (job #265673) | Cod sursa (job #2811634) | Cod sursa (job #260977)
Cod sursa(job #260977)
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.