rt,样例过了,下载的数据本地过了而且速度很快,前三个点tle,其他点wa,提示
Wrong Answer.wrong answer Too short on line N.
代码
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
inline ll read(){
ll 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-'0';
ch=getchar();
}
return x*f;
}
void write(ll x){
if(x<0){
x=-x;
putchar('-');
}
if(x>9){
write(x/10);
}
putchar(x%10+'0');
}
const ll N=1e5+9,logN=30;
ll st[N][logN];
ll n,m;
ll lg[N];
ll a[N];
void init(){
lg[0]=-1;
for(int i=1;i<=N;i++){
lg[i]=lg[i/2]+1;
}
for(int i=n;i>=1;i--){
for(int j=0;i+(1<<j)-1<=n;j++){
if(j==0){
st[i][j]=a[i];
}
else{
st[i][j]=max(st[i][j-1],st[i+(1<<(j-1))][j-1]);
}
}
}
}
int main(){
n=read();
m=read();
for(int i=1;i<=n;i++){
a[i]=read();
}
init();
for(int i=1;i<=m;i++){
ll l=read(),r=read();
write(max(st[l][lg[r-l+1]],st[r-(1<<lg[r-l+1])+1][lg[r-l+1]]));
putchar('\n');
}
return 0;
}
尝试把o2关了但是还是一样