Pagini recente » Cod sursa (job #2564033) | Cod sursa (job #2316496) | Cod sursa (job #2482176) | Cod sursa (job #731857) | Cod sursa (job #399531)
Cod sursa(job #399531)
var i,n,s,nr,p,smax,pmax,max:longint;
a:array[1..6000000]of longint;
f:text;
procedure ssm;
begin
s:=0;
smax:=1;
pmax:=1;
nr:=0;
p:=1;
max:=a[i];
for i:=1 to n do
begin
s:=s+a[i];inc(nr);
if s>max then begin
max:=s;
smax:=nr;
pmax:=p;
end;
if s<0 then begin
s:=0;
p:=i+1;
nr:=0;
end;
end;
end;
begin
assign(f,'ssm.in');
reset(f);
readln(f,n);
for i:=1 to n do read(f,a[i]);
close(f);
ssm;
assign(f,'ssm.out');
rewrite(f);
writeln(f,max,' ',pmax,' ',pmax+smax-1);
close(f);
end.