![[백준 알고리즘] 10828번 스택 (Python, Java)](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fk09vn%2FbtqCGRyHtF5%2F3bxN6RtYOUSVFx4cY1aOkK%2Fimg.png)
언어, 알고리즘 공부/백준2020. 3. 12. 20:30[백준 알고리즘] 10828번 스택 (Python, Java)
import sys N = int(input()) stack = [] for _ in range(N): line = sys.stdin.readline().split() if line[0] == "push": stack.append(int(line[1])) elif line[0] == "pop": if len(stack)>0: print(stack[-1]) stack.pop() else: print(-1) elif line[0] == "size": print(len(stack)) elif line[0] == "empty": if len(stack) == 0: print(1) else: print(0) elif line[0] == "top": if len(stack) > 0: print(stack[-1]) ..