Pagini recente » Cod sursa (job #2750043) | Cod sursa (job #2116495) | Cod sursa (job #1757091) | Cod sursa (job #2972991) | Cod sursa (job #243438)
Cod sursa(job #243438)
var n,m,a,b,c,i,v,x,y,max,poz:longint;
arb:array[1..300001] of longint;
function maxi(a,b:longint):longint; inline;
begin
if a>b then maxi:=a
else maxi:=b;
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 poz<=mij then refresh(2*nod,li,mij)
else refresh(2*nod+1,mij+1,ls);
arb[nod]:=maxi(arb[2*nod],arb[2*nod+1]);
end;
end;
procedure ask(nod,li,ls:longint); inline;
var mij:longint;
begin
if (x<=li)and(ls<=y) 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); poz:=i;
refresh(1,1,n);
end;
for i:=1 to m do
begin
readln(c,a,b);
if c=0 then
begin
max:=0;
x:=a; y:=b;
ask(1,1,n); writeln(max);
end
else
begin
poz:=a; v:=b;
refresh(1,1,n);
end;
end;
close(input); close(output);
end.