Pagini recente » Cod sursa (job #1217493) | Cod sursa (job #2099978) | Cod sursa (job #3168695) | Cod sursa (job #695013) | Cod sursa (job #688771)
Cod sursa(job #688771)
var v,t:array[0..6000000] of longint;
s,sf,df,m,i,j,n:longint;
o,d:text;
{function max(a,b:longint):longint;
begin
max:=a;
if b>max then max:=b;
end;}
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.