
앞 전 문제와 유사한 최소힙 문제이다.역시나 파이썬이기 때문에 heapq 라이브러리를 사용해주면 간단하게 해결할 수 있다. import sysimport heapqN = int(input())heap = [] # 최소 힙for _ in range(N): calc = list(map(int, sys.stdin.readline().split())) for num in calc: if num == 0: if heap: print(heapq.heappop(heap)) else: print(0) else: heapq.heappush(heap, num) 조건에서 시간 제한이 눈에 띄길래 입력 문자열을 input() 대신 ..