我在自己电脑上跑这个程序的这个数据(下载的#1)是正确的的,但是洛谷显示我9组WA,#1的输出第一位是"6"。想请人帮忙试试在别的电脑上难道运行不一样吗 提交记录:https://www.luogu.com.cn/record/135446046
#include<bits/stdc++.h>
using namespace std;
int n,m,l,r,st[100005][20],t,p2[100005],tt,mx;
inline int lb(int x){
return x&-x;
}
int main(){
while((1<<t)<=100000) p2[(1<<t)]=t++;
t--;
cin>>n>>m;
for(int i=1;i<=n;i++){
scanf("%d",&st[i][0]);
}
for(int i=1;i<=t;i++){
for(int j=1;j+(1<<(i-1))<=n;j++){
st[j][i]=max(st[j][i-1],st[j+(1<<(i-1))][i-1]);
}
}
while(m--){
scanf("%d%d",&l,&r);
//t=r-l+1;
mx=st[l][0];
while(l<=r){
tt=lb(r-l+1);
mx=max(mx,st[l][p2[tt]]);
l+=tt;
//t-=tt;
}
//cout<<mx<<endl;
printf("%d\n",mx);
}
return 0;
}
date:
10 10
34510650 17635986 629392810 531021973 464687714 484934800 168882190 645518365 922058895 397659551
2 9
1 8
1 7
2 10
3 9
4 10
3 10
1 7
2 10
2 8