Pagini recente » Cod sursa (job #3031364) | Cod sursa (job #2009603) | Cod sursa (job #2336196) | Cod sursa (job #2752549) | Cod sursa (job #702056)
Cod sursa(job #702056)
program subsecventa;
var f,g:text;
n,i,j,min,max,poz1,poz2:longint;
v:array[1..6000000] of longint;
bufin,bufout:array[1..65000] of byte;
s:array[0..6000000] of longint;
begin
assign (F,'ssm.in'); reset (F);
assign (g,'ssm.out'); rewrite (G);
settextbuf (f,bufin);
settextbuf (g,bufout);
readln (f,n);
for i:=1 to n do
begin
read (f,v[i]); s[i]:=s[i-1]+v[i];
end;
min:=v[1];
max:=-maxlongint;
j:=1;
for i:=2 to n do
begin
if s[i]-min>max then
begin
max:=s[i]-min;
poz1:=j+1;
poz2:=i;
end;
if s[i]<min then
begin
min:=s[i]; j:=i;
end;
end;
write (g,max,' ' ,poz1,' ',poz2);
close (f); close (g);
end.