✔ 풀이를 위한 아이디어
✔ 코드
import sys
n = int(sys.stdin.readline())
want = [int(sys.stdin.readline()) for _ in range(n)]
current_index = 0
answer_list = []
answer_list.append('+')
stack = [i+1 for i in range(n)]
black_list = [0] * n
i = 0
while i < n:
if want[i] > stack[current_index]:
answer_list.append('+')
current_index += 1
while black_list[current_index] == 1:
current_index += 1
elif want[i] == stack[current_index]:
answer_list.append('-')
black_list[current_index] = 1
while black_list[current_index] == 1:
if current_index > 0:
current_index -= 1
else:
break
i += 1
elif want[i] < stack[current_index]:
print("NO")
sys.exit()
for i in range(len(answer_list)):
print(answer_list[i])
✔ 관련 개념