코드 import heapq, sys input = sys.stdin.readline tc = int(input()) hq= [] for _ in range(tc): x = int(input()) if x == 0: print(heapq.heappop(hq)[1]) if hq else print(0) else: heapq.heappush(hq, (abs(x),x)) 우선순위 큐에 넣는 자료형이 단일 값이 아닌 선형 자료구조면(ex. 리스트, 튜플 등) 기본적으로 맨 앞 요소부터 우선적으로 살펴보며 정렬한다.