[백준/Python] 28278번 스택 2
·
알고리즘문제풀이
문제https://www.acmicpc.net/problem/28278문제 이해문제 이름과 같이 스택에 관한 문제이다.명령어(1~5)에 따라 명령을 수행하면 되는 차례대로 풀면 되는 문제이다.문제 풀이(정답)import sysinput=sys.stdin.readlin n = int(input())stack = []for _ in range(n): cmd = input().split() if cmd[0] == '1': stack.append(cmd[1]) elif cmd[0] == '2': if len(stack) == 0: print(-1) else: print(stack.pop()) elif cmd[0] ..