Pagini recente » Cod sursa (job #2637760) | Cod sursa (job #1655719) | Cod sursa (job #1915508) | Profil zaqwsx | Cod sursa (job #458845)
Cod sursa(job #458845)
var a:array[1..264000] of longint;
n,m,i,op,x,y,max,k:longint;
s:string;
procedure helyettesit(bog,b,j:longint);
var koz:longint;
begin
if b>=j then
begin
a[bog]:=y;
exit;
end
else
begin
koz:=(j+b)shr 1;
if x<koz then helyettesit((bog shl 1),b,koz)
else helyettesit((bog shl 1)+1,koz+1,j);
if a[bog shl 1]>a[(bog shl 1)+1] then
a[bog]:=a[(bog shl 1)]
else
a[bog]:=a[(bog shl 1)+1];
end;
end;
procedure maximum(bog,b,j:longint);
var koz:longint;
begin
if (x<=b) and (y>=j) then
begin
if max<a[bog] then max:=a[bog];
exit;
end
else
begin
koz:=(j+b) shr 1;
if x<=koz then maximum(bog shl 1, b, koz);
if y>koz then maximum((bog shl 1)+1, koz+1, j);
end;
end;
begin
assign(input,'arbint.in'); reset(input);
assign(output,'arbint.out'); rewrite(output);
readln(n,m);
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;
helyettesit(1,1,n);
y:=0;
end
else
y:=y*10+(ord(s[k])-48);
end;
end;
if s[k]<>' ' then helyettesit(1,1,n);
for i:=1 to m do
begin
read(op,x,y);
if op=1 then helyettesit(1,1,n)
else
begin
max:=0;
maximum(1,1,n);
writeln(max);
end;
end;
close(output);
end.