非常奇妙
这个样例不过零分
#include <cstdio>
using namespace std;
int n,m;
char c;
int a[1000001];
void opt1(){
int x,y,maxn=-1;
scanf("%d%d",&x,&y);
for(int i=x;i<=y;++i){
if(a[i]>=maxn)
maxn=a[i];
}
printf("%d\n",maxn);
}
void opt2(){
int x,y;
scanf("%d%d",&x,&y);
if(a[x]<y)a[x]=y;
}
int main() {
scanf("%d%d",&n,&m);
for(int i=1;i<=n;++i)
scanf("%d",&a[i]);
while(m--){
scanf("%c",&c);
if(c=='Q')opt1();
if(c=='U')opt2();
}
return 0;
}
加上 m 乘三就 ac?为啥?```cpp #include using namespace std; int n,m; char c; int a[1000001]; void opt1(){ int x,y,maxn=-1; scanf("%d%d",&x,&y); for(int i=x;i<=y;++i){ if(a[i]>=maxn) maxn=a[i]; } printf("%d\n",maxn); } void opt2(){ int x,y; scanf("%d%d",&x,&y); if(a[x]<y)a[x]=y; } int main() { scanf("%d%d",&n,&m);
for(int i=1;i<=n;++i)
scanf("%d",&a[i]);
m*=3;
while(m--){
scanf("%c",&c);
if(c=='Q')opt1();
if(c=='U')opt2();
}
return 0;
}