백준 알고리즘 1874번
자료구조 스택 활용하기
파이썬
import sys
input = sys.stdin.readline
cnt=1
temp = True
s = []
a = []
n = int(input())
for i in range (n):
num = int(input())
while cnt <= num:
s.append(cnt)
a.append('+')
cnt+=1
if s[-1] == num:
s.pop()
a.append('-')
else:
temp=False
break
if temp == False:
print("NO")
else:
for i in a:
print(i)
댓글남기기