Pagini recente » Cod sursa (job #125024) | Cod sursa (job #738047) | Cod sursa (job #1352431) | Cod sursa (job #1851753) | Cod sursa (job #689600)
Cod sursa(job #689600)
var a,v:array[0..6000000] of integer;
i,n,bb,aa,a1,b,max,s:integer;
f,g:text;
begin
assign(f,'ssm.in'); reset (f);
assign(g,'ssm.out'); rewrite (g);
readln (f,n);
for i:=1 to n do
read (f,v[i]);
max:=-maxint;
b:=1;
for i:=1 to n do
begin s:=v[i]+a[i-1];
if (s>a[i]) then a[i]:=s
else begin a[i]:=v[i];
a1:=i;
end;
if (max<=a[i]) then begin max:=a[i]; aa:=a1; bb:=b; end;
b:=b+1;
end;
write (g,max,' ',aa,' ',bb);
close (f);
close (g);
end.