Pagini recente » Cod sursa (job #1312477) | Cod sursa (job #278157) | Cod sursa (job #839142) | Cod sursa (job #1326570) | Cod sursa (job #695128)
Cod sursa(job #695128)
var smax,sc,poz,sf,i,n,inceput,x:longint; f:text;
begin
assign(f,'ssm.in'); reset(f);
readln(f,n);
read(f,smax);
sc:=smax;
poz:=1;
inceput:=1;
sf:=1;
for i:=2 to n do begin read(f,x);
if sc<0 then begin
sc:=x;
poz:=i;
end else sc:=sc+x;
if smax<sc then begin
smax:=sc;
inceput:=poz;
sf:=i;
end;
end;
close(f);
assign(f,'ssm.out'); rewrite(f);
write(f,smax,' ',inceput,' ',sf); close(f);
end.