목록Algorithm/Ch 1. 기초 자료구조 (2)
토니의 연습장
https://www.acmicpc.net/problem/18258Dequeue 활용import sysfrom collections import dequeN = int(input())# N = int(sys.stdin.readline().strip())d = deque([])for i in range(N): # input() # 입력 여러 개가 들어올 때는 readline이 더 빨라 권고됨 command = sys.stdin.readline() command = command.split() match command[0]: case "push": d.append(command[1]) case "pop": if le..
https://www.acmicpc.net/problem/10773K = int(input())stack = []for i in range(K): n = int(input()) if n == 0: stack.pop(-1) else: stack.append(n) sum = 0for e in stack: sum += e print(sum)https://www.acmicpc.net/problem/4949 while True: s = input() if s == ".": break stack = [] balanced = True for i in range(len(s)): ..