Pagini recente » Cod sursa (job #2671437) | Cod sursa (job #2298635) | Cod sursa (job #1602689) | Cod sursa (job #1715110) | Cod sursa (job #272130)
Cod sursa(job #272130)
program subsecventa;
type vector=array[1..6000000] of record
x,y,z:longint;end;
var a:vector;
i,j,n,m,min,poz,p,q,fin:longint;
f,g:text;
s:longint;
begin
assign(f,'ssm.in');assign(g,'ssm.out');reset(f);rewrite(g);
readln(f,n);s:=0;
read(f,m);s:=m;min:=0;a[1].x:=1;a[1].y:=s;a[1].z:=min;poz:=1;
for i:=2 to n do begin
read(f,m);
s:=s+m;
if s<min then begin min:=s;poz:=i;end;
a[i].x:=poz;a[i].y:=s;a[i].z:=min;end;
p:=a[1].y;
q:=1;fin:=1;
for i:=2 to n do begin
if (a[i].y-a[i].z)>p then begin
p:=a[i].y-a[i].z;
q:=a[i].x;fin:=i;end
else if a[i].y-a[i].z=p then
if i-a[i].x<fin-q then
begin fin:=i;q:=a[i].x;end;end;
close(f);
write(g,p,' ',q+1,' ',fin);
close(g);
end.