꾸준하게
<백준> 1874번 파이썬 알고리즘 본문
n = int(input())
res = []
stk = []
cnt = 1
temp = True
for _ in range(n):
m = int(input())
while cnt <= m:
res.append('+')
stk.append(cnt)
cnt += 1
if stk[-1] == m:
stk.pop()
res.append('-')
else:
temp = False
if temp == False:
print('NO')
else:
for i in res:
print(i)
포인트는 스텍에 오름차순으로 넣는다는 것!
'테크 > 알고리즘' 카테고리의 다른 글
| <백준> 1966번 파이썬 알고리즘 (0) | 2021.07.06 |
|---|---|
| <백준> 1929번 파이썬 알고리즘 (0) | 2021.07.06 |
| <백준> 1920번 파이썬 알고리즘 (0) | 2021.07.06 |
| <백준> 1436번 파이썬 알고리즘 (0) | 2021.07.05 |
| <백준> 1259번 파이썬 알고리즘 (0) | 2021.07.05 |