建议加强数据
查看原帖
建议加强数据
1416713
gzzym123456楼主2025/8/31 19:45

O(nm)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;
}
2025/8/31 19:45
加载中...