C++#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e6+10;
ll n,l,r,tree[N],arr[N],m,opt;
inline ll lowbit(ll x){return x&(-x);}
inline void update(ll pos,ll val){//单点更新
arr[pos]=val;
while(pos<=n){
if(val>tree[pos]){
tree[pos]=val;
}else{
ll temp=arr[pos];
for(ll k=1;k<lowbit(pos);k<<=1){
if(tree[pos-k]>temp) temp=tree[pos-k];
}
tree[pos]=temp;
}
pos+=lowbit(pos);
}
return ;
}
inline ll query(ll l,ll r){//区间查询
ll res=INT_MIN;
while(r>=l){
if(r-lowbit(r)+1>=l){
if(tree[r]>res) res=tree[r];
r-=lowbit(r);
}else{
if(arr[r]>res) res=arr[r];
r--;
}
}
return res;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin>>n>>m;
for(ll i=1;i<=n;i++){
tree[i]=INT_MIN;
arr[i]=INT_MIN;
}
for(ll i=1;i<=n;i++){
cin>>arr[i];
update(i,arr[i]);
}
while(m--){
cin>>opt;
if(opt==1){//更改
cin>>l>>r;
update(l,r);
}else{//查询
cin>>l>>r;
cout<<query(l,r)<<'\n';
}
}
return 0;
}
/*
题意:有n个数和m次操作;
输入n和m,输入n个数a[i];
对于操作一,输入形如 1,x,y 表示将a[x]更改为y;
对于操作二,输入形如 2,x,y 表示输出a[x]—a[y]的区间最大值
*/