Pagini recente » Cod sursa (job #2785172) | Cod sursa (job #2051166) | Istoria paginii utilizator/yamasfurniture | Cod sursa (job #1757009) | Cod sursa (job #1414819)
program ssm;
type tabel=array[0..6000001] of longint;
buf=array[0..1 shl 17] of char;
var t,s:tabel; ff1,ff2:buf;
n,i,j,aux,max,ii,x:longint;
begin
assign (input,'ssm.in');
assign (output,'ssm.out');
reset (input);
rewrite (output);
settextbuf(input,ff1);
settextbuf(output,ff2);
readln (n);
for i:=1 to n do read (t[i]);
for i:=1 to n do
s[i]:=s[i-1]+t[i];
max:=-10000000; x:=0;
for i:=1 to n do begin
if s[i]-x>max then begin
max:=s[i]-x; ii:=aux+1; j:=i; end;
if s[i]<x then begin
x:=s[i]; aux:=i;
end; end;
writeln (max,' ',ii,' ',j);
close (input);
close (output);
end.