Pagini recente » Statistici Opran Alexandru (Alex.QTK10) | Profil M@2Te4i | Cod sursa (job #1264331) | Profil AntoniaComsa | Cod sursa (job #1240464)
program ssm;
type
tabel=array[0..6000002] of longint;
buf=array[0..1 shl 17] of longint;
var
ff1,ff2:buf;
t:tabel;
max,i,j,aux,x,n,ii:longint;
f1,f2:text;
begin
assign (f1,'ssm.in');
assign (f2,'ssm.out');
reset (f1);
rewrite (f2);
settextbuf(f1,ff1);
settextbuf(f2,ff2);
readln (f1,n);
for i:=1 to n do begin
read(f1,x);
t[i]:=t[i-1]+x;
end;
x:=0; max:=-100000000;
for i:=1 to n do begin
if max<t[i]-x then begin max:=t[i]-x; ii:=aux+1; j:=i; end;
if t[i]<x then begin x:=t[i]; aux:=i; end;
end;
writeln (f2,max,' ',ii,' ',j);
close (f1);
close (f2);
end.