Algorithm/BOJ 기초
[백준] 스택수열 1874 Python
hackyu
2019. 9. 28. 03:55
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | N = int(input()) obj = [] stack = [] result = [] idx = 0 for i in range(N): obj.append(int(input())) for i in range(1, N+1): stack.append(i) result.append("+") while idx < N and len(stack) != 0 and obj[idx] == stack[-1]: stack.pop() result.append("-") idx += 1 if not stack: for i in result: print(i) else: print("NO") | cs |