-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathC.cpp
52 lines (49 loc) · 1.01 KB
/
C.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include<bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0);cin.tie(0)
long long ara[100005];
int main()
{
fastio;
long long n,m,i,l,r;
cin>>n>>m;
vector<long long> asc,desc;
for(i=0;i<n;i++)
{
cin>>ara[i];
if(i>0)
{
if(ara[i]>ara[i-1])
asc.push_back(i+1);
else if(ara[i]<ara[i-1])
desc.push_back(i+1);
}
}
while(m--)
{
cin>>l>>r;
vector<long long>::iterator it1,it2;
it1=upper_bound(desc.begin(),desc.end(),l);
if(it1==desc.end())
{
cout<<"Yes\n";
continue;
}
if((*it1)>=r)
{
cout<<"Yes\n";
continue;
}
it2=upper_bound(asc.begin(),asc.end(),*(it1));
if(it2==asc.end())
{
cout<<"Yes\n";
continue;
}
if(*(it2)>r)
cout<<"Yes\n";
else
cout<<"No\n";
}
return 0;
}