O(nm) 实测时间复杂度可以AC,915ms
#include<bits/stdc++.h>
using namespace std;
int n,m,a[200001];
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin>>n>>m;
for(int i=1;i<=n;i++)cin>>a[i];
for(int i=1;i<=m;i++)
{
char c;
int x,y;
cin>>c>>x>>y;
if(c=='Q')
{
int maxn=-114514;
for(int j=x;j<=y;j++)maxn=max(maxn,a[j]);
cout<<maxn<<"\n";
}
else a[x]=max(a[x],y);
}
return 0;
}