-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPilingUp!.py
More file actions
32 lines (27 loc) · 760 Bytes
/
Copy pathPilingUp!.py
File metadata and controls
32 lines (27 loc) · 760 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
# Enter your code here. Read input from STDIN. Print output to STDOUT
import sys
from collections import deque
if __name__ == '__main__':
n = int(input())
res = []
for i in range(n):
l = int(input())
d = deque(map(int, input().split(' ')))
q = sys.maxsize
result = 'Yes'
while len(d) > 0:
if d[0] <= q and d[-1] <= q:
if d[0] >= d[-1]:
q = d.popleft()
else:
q = d.pop()
elif d[0] <= q:
q = d.popleft()
elif d[-1] <= q:
q = d.pop()
else:
result = 'No'
break
res.append(result)
for i in res:
print(i)