-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathSTPAR.py
More file actions
36 lines (28 loc) · 692 Bytes
/
STPAR.py
File metadata and controls
36 lines (28 loc) · 692 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
def answer(size,case):
need=1
status= True
lane=[]
for e in case:
while(bool(len(lane)) and lane[-1]==need):
need+=1
lane.pop()
if e==need:
need+=1
elif bool(len(lane)) and e>lane[-1]:
status=False
return status
else:
lane.append(e)
return status
def main():
while True:
n=input()
if n==0:
break
else:
case=map(int,(raw_input().split()))
if answer(n,case):
print "yes"
else:
print "no"
main()