-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB_Seating_in_a_Bus.cpp
More file actions
53 lines (36 loc) · 1019 Bytes
/
B_Seating_in_a_Bus.cpp
File metadata and controls
53 lines (36 loc) · 1019 Bytes
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
53
# include <iostream>
# define ll long long
#include <bits/stdc++.h>
#define FAST \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
using namespace std ;
unsigned ll dist(ll x ,ll y , ll x1 , ll y1 ){
unsigned ll ditx = (x1 -x)*(x1 -x);
unsigned ll dity = ( y1 - y)*( y1 - y);
unsigned ll ans = ditx + dity;
return ans;
}
int main (){
FAST
ll t; cin >> t; while (t--){
ll n ; cin >> n; ll arr[n];
for(ll i = 0 ;i < n;i++){
cin >> arr[i];
}
ll l = arr[0] -1; ll r = arr[0] +1;
ll fl = 1;
for(ll i = 1 ;i < n;i++){
if(arr[i] == l){
l--;
}else if (arr[i] == r){
r++;
} else {
fl = 0;
cout << "NO\n";break;
}
}
if(fl) cout << "YES\n";
}
}