Pagini recente » Rating Balauta Albert (Balauta_Albert) | Cod sursa (job #3292924) | Cod sursa (job #3277012) | Cod sursa (job #2445875) | Cod sursa (job #273123)
Cod sursa(job #273123)
program suma;
var f:text;
s,smax,i,n,a,ii1,nr,is1:longint;
begin
assign(f,'ssm.in');
reset(f);
read(f,n);
read(f,smax);
smax:=-maxlongint;
s:=0;
for i:=2 to n do begin
read(f,a);
s:=s+a;
if s>=0 then
inc(nr);
if s>smax then begin
ii1:=i-nr+1;
smax:=s;
is1:=i;
end;
if s<0 then begin s:=0; nr:=0; end;
end;
close(f);
assign(f,'ssm.out');
rewrite(f);
if smax>0 then
write(f,smax,' ',ii1,' ',is1)
else write(f,smax,' ',ii1-1,' ',is1);
close(f);
end.