-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCLRL.cpp
48 lines (44 loc) · 985 Bytes
/
CLRL.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
#include <iostream>
#include <climits>
using namespace std;
int main() {
int t;
cin>>t;
while(t--)
{
int n,flag=0;
cin>>n;
int re;
cin>>re;
int seq[n];
for(int i=0;i<n;i++)
{
cin>>seq[i];
}
int diff=abs(seq[0]-seq[1]);
int left = INT_MIN;
int right =INT_MAX;
for(int i=0;i<n;i++)
{
if(seq[i]<=left || seq[i]>=right)
{
flag=1;
break;
}
else if(seq[i]>re)
{
right = seq[i];
}
else if(seq[i]<re)
{
left = seq[i];
}
}
if(flag)
{
cout<<"NO"<<endl;
}
else cout<<"YES"<<endl;
}
return 0;
}