Pagini recente » Cod sursa (job #942453) | Cod sursa (job #1237289) | Cod sursa (job #2304297) | Cod sursa (job #2828376) | Cod sursa (job #186676)
Cod sursa(job #186676)
var op,x,y,i,a,b,n,m,max,poz,v:longint;
arb:array[1..300001] of longint;
function maxim(p,q:longint):longint;
begin
if p>q then maxim:=p else maxim:=q;
end;
procedure refresh(nod,li,ls:longint);inline;
var mij:longint;
begin
if li=ls then arb[nod]:=v
else
begin
mij:=(li+ls) div 2;
if i<=mij then refresh(2*nod,li,mij)
else refresh(2*nod+1,mij+1, ls);
arb[nod]:=maxim(arb[2*nod],arb[2*nod+1]);
end;
end;
procedure ask(nod,li,ls:longint); inline;
var mij:longint;
begin
if (x<=li)and(y>=ls) then begin if arb[nod]>max then max:=arb[nod]; end
else
begin
mij:=(li+ls) div 2;
if x<=mij then ask(2*nod,li,mij);
if y>mij then ask(2*nod+1,mij+1,ls);
end;
end;
begin
assign(input,'arbint.in'); reset(input); assign(output,'arbint.out'); rewrite(output);
readln(n,m);
for i:=1 to n do
begin
read(v);
refresh(1,1,n);
end;
for a:=1 to m do
begin
readln(op,i,b);
if op=0 then
begin
max:=-1; x:=i; y:=b; ask(1,1,n);
writeln(max);
end
else
begin
v:=b; refresh(1,1,n);
end;
end;
close(input); close(output);
end.