Pagini recente » Cod sursa (job #2298460) | Cod sursa (job #1714687) | Cod sursa (job #431583) | Cod sursa (job #1656068) | Cod sursa (job #342196)
Cod sursa(job #342196)
var i,j,n,b,incepe,x,l,max,maxi,maxl:longint;
t:text;
begin
b:=-maxlongint;
assign(t,'ssm.in'); reset(t);
readln(t,n);
for i:=1 to n do
begin
read(t,x);
if (x>b+x) then
begin
b:=x;
incepe:=i;
l:=1;
end
else if (b+x>x) then
begin
b:=b+x;
inc(l);
end;
if ((max<b) or ((max=b)and(incepe<=maxi)and(l<maxl))) then
begin
max:=b;
maxi:=incepe;
maxl:=l;
end;
end;
close(t);
assign(t,'ssm.out'); rewrite(t);
writeln(t,max,' ',maxi,' ',maxi+maxl-1);
close(t);
end.