Pagini recente » Cod sursa (job #2713431) | Cod sursa (job #3247299) | concurs-mihai-patrascu-2013/clasament | Cod sursa (job #2786707) | Cod sursa (job #360865)
Cod sursa(job #360865)
var a:array[1..264000] of longint;
n,m,i,op,x,y,maxim,k:longint;
s:string;
procedure inlocuieste(nod,st,dr:longint);
var mij:longint;
begin
if st>=dr then begin a[nod]:=y; exit; end
else begin
mij:=(st+dr)shr 1;
if x<=mij then
inlocuieste((nod shl 1),st,mij) else
inlocuieste((nod shl 1)+1,mij+1,dr);
if a[nod shl 1]>a[(nod shl 1)+1] then
a[nod]:=a[(nod shl 1)] else
a[nod]:=a[(nod shl 1)+1];
end;
end;
procedure max(nod,st,dr:longint);
var mij:longint;
begin
if (x<=st) and (y>=dr) then begin
if maxim<a[nod] then maxim:=a[nod]; exit; end
else begin
mij:=(st+dr) shr 1;
if x<=mij then max(nod shl 1,st,mij);
if y>mij then max((nod shl 1)+1,mij+1,dr);
end;
end;
begin
assign(input,'arbint.in');
reset(input);
assign(output,'arbint.out');
rewrite(output);
readln(n,m);{
k:=1;
read(s);
for x:=1 to n do begin
y:=0;
while (s[k]<>' ') do begin
y:=y*10+ord(s[k])-48;
k:=k+1;
if (k=length(s)+1) then begin
read(s);
k:=1;
end;
end;
k:=k+1;
inlocuieste(1,1,n);
end; }
y:=0;
x:=0;
while (not(eoln(input))) do begin
read(s);
for k:=1 to length(s) do begin
if s[k]=' ' then begin
x:=x+1;
inlocuieste(1,1,n);
y:=0;
end else y:=y*10+(ord(s[k])-48);
end;
end;
inlocuieste(1,1,n);
for i:=1 to m do begin
read(op,x,y);
if op=1 then begin
inlocuieste(1,1,n);
end else begin
maxim:=0;
max(1,1,n);
writeln(maxim);
end;
end;
close(output);
end.