Pagini recente » Cod sursa (job #2963193) | Cod sursa (job #2597401) | Cod sursa (job #1810492) | Cod sursa (job #890162) | Cod sursa (job #260920)
Cod sursa(job #260920)
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.