Pagini recente » Cod sursa (job #2569182) | Cod sursa (job #2840115) | Cod sursa (job #2878501) | Cod sursa (job #387413) | Cod sursa (job #693052)
Cod sursa(job #693052)
var v,t:array[0..6000000] of longint;
s,sf,df,m,i,j,n:longint;
o,d:text;
begin
assign(o,'ssm.out');assign(d,'ssm.in');
reset(d);rewrite(o);
read(d,n);
sf:=1;s:=1;
df:=1;
read(d,v[1]);
m:=v[1];
t[0]:=-maxlongint;
t[1]:=v[1];
for i:=2 to n do
begin
read(d,v[i]);
if v[i]>(t[i-1]+v[i])
then
begin
s:=i;
t[i]:=v[i];
end
else
begin
t[i]:=t[i-1]+v[i];
end;
if t[i]>m then begin m:=t[i];sf:=s;df:=i end;
end;
write(o,m,' ',sf,' ',df);
close(o);close(d);
end.