Pagini recente » Cod sursa (job #524635) | Cod sursa (job #2745942) | Cod sursa (job #1380277) | Cod sursa (job #2315188) | Cod sursa (job #743354)
Cod sursa(job #743354)
Program secv_max;
var i,n,j1,j2,max,sum,x,poz:longint;
bufi,bufa : array[0..1 shl 20] of char;
begin
assign(input,'ssm.in'); reset(input);
assign(output,'ssm.out'); rewrite(output);
settextbuf(input,bufi); settextbuf(output,bufa);
max:=-2147483648; sum:=0; readln(n);
for i:=1 to n do begin
read(x);
if sum<0 then begin sum:=x; j1:=i; end
else sum:=sum+x;
if max<sum then begin max:=sum; poz:=j1; j2:=i; end;
end;
write(max,' ',poz,' ',j2);
end.