Skip to content

Commit 1110433

Browse files
committed
new file
1 parent 9f7e52a commit 1110433

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

Pilling Up.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from collections import deque
2+
user = int(input())
3+
while user > 0:
4+
t = int(input())
5+
l1 = list(map(int, input().split()))
6+
t1 = deque(l1)
7+
lm = t1.popleft()
8+
rm = t1.pop()
9+
csv = lm if lm > rm else rm
10+
flag = False
11+
while len(t1) > 0:
12+
if lm >= rm and lm <= csv:
13+
csv = lm
14+
lm = t1.popleft()
15+
latest = lm
16+
elif rm >= lm and rm <= csv:
17+
csv = rm
18+
rm = t1.pop()
19+
latest = rm
20+
else:
21+
flag = True
22+
break
23+
24+
if flag or latest > csv:
25+
print('No')
26+
else:
27+
print('Yes')
28+
29+
user -= 1

0 commit comments

Comments
 (0)