-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPiling Up.py
32 lines (24 loc) · 859 Bytes
/
Piling Up.py
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
"""
There is a horizontal row of cubes. The length of each cube is given. You need to create a new vertical pile of cubes.
The new pile should follow these directions: if is on top of then .
When stacking the cubes, you can only pick up either the leftmost or the rightmost cube each time.
Print "Yes" if it is possible to stack the cubes. Otherwise, print "No". Do not print the quotation marks.
"""
from typing import List
numbers: List[List[int]] = []
def pile():
n = int(input())
for i in range(n):
sides = input()
m = list(map(int, input().split()))
numbers.append(m)
# print(numbers)
def checker():
for n in range(len(numbers)):
if numbers[n][0] < numbers[n][-1]:
print("No")
else:
del numbers[n][0]
del numbers[n][-1]
print("Yes")
print(pile())