题解
找到每一个点右边能递增多远和左边能递增多远
code
#include<bits/stdc++.h>
using namespace std;
int a[100005],r[100005],l[100005];
int main()
{
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++) cin>>a[i];
r[n]=n;
for(int i=n-1;i>=1;i--)
{
if(a[i]<=a[i+1]) r[i]=r[i+1];
else r[i]=i;
}
l[1]=1;
for(int i=2;i<=n;i++)
{
if(a[i]<=a[i-1]) l[i]=l[i-1];
else l[i]=i;
}
while(m--)
{
int x,y;
cin>>x>>y;
if(r[x]>=l[y]) puts("Yes");
else puts("No");
}
return 0;
}
标签:多远,puts,int,Ladder,100005,递增
From: https://www.cnblogs.com/pure4knowledge/p/18243629