rt
时间不够
其他全AC,56分代码
有没有dalao神犇来帮我改改啊
// LG-P3865.cpp
#include <cstdio>
#include <iostream>
using namespace std;
inline int read()
{
int x=0,f=1;char ch=getchar();
while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
while (ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
return x*f;
}
typedef long long ll;
const int maxn=2e5+5;
int n,m;
int a[maxn];
int f[maxn][21],log_2[maxn];
int main(){
n=read();
m=read();
for(int i=1;i<=n;i++){
a[i]=read();
f[i][0]=a[i];
}
for(int i=1;i<=20;i++)
for(int j=1;j+(1<<i)-1<=n;j++)
f[j][i]=max(f[j][i-1],f[j+(1<<(i-1))][i-1]);
for(int i=2;i<=n;i++)
log_2[i]=log_2[i/2]+1;
while(m--){
int l,r,s,ans;
l=read();
r=read();
s=log_2[r-l+1];
ans=max(f[l][s],f[r-(1<<s)+1][s]);
cout<<ans<<endl;
}
return 0;
}