Pagini recente » Romanian IOI Medalists: Careers | Cod sursa (job #951295) | Cod sursa (job #2960938) | Cod sursa (job #1718359) | Cod sursa (job #279831)
Cod sursa(job #279831)
program subsecventa_de_suma_maxima;
var f,g:text;
sc,x,max,p1,p2,i,pc,n:longint;
begin
assign(f,'ssm.in');
assign(g,'ssm.out');
reset(f);
rewrite(g);
readln(f,n);
read(f,x);
sc:=x;
max:=x;
p1:=1;
p2:=1;
pc:=1;
i:=2;
while i<=n do begin
read(f,x);
if sc+x>0 then begin
sc:=sc+x;
if sc>max then begin
max:=sc;
p1:=pc;
p2:=i;
end;
end
else begin
inc(i);
read(f,x);
pc:=i;
sc:=x;
end;
inc(i);
end;
writeln(g,max,' ',p1,' ',p2);
close(f);
close(g);
end.