Machineboy空
백준 11286번: 절댓값 힙 구현하기 - Priority Queue, Heap 본문

from queue import PriorityQueue
import sys
print = sys.stdout.write
input = sys.stdin.readline
N = int(input())
myQueue = PriorityQueue()
for i in range(N):
request = int(input())
if request == 0:
if myQueue.empty():
print('0\n')
else:
temp = myQueue.get()
print(str((temp[1]))+'\n')
else:
myQueue.put((abs(request),request))
'Computer > Coding Test' 카테고리의 다른 글
백준 2164번: 카드2 - Queue (0) | 2023.10.21 |
---|---|
백준 2750번: 수 정렬하기 - 버블 정렬 (0) | 2023.10.19 |
백준 12891번: DNA 비밀번호 - 슬라이딩 윈도우 (1) | 2023.10.17 |
백준 2018번: 수들의 합 (투 포인터) (1) | 2023.10.17 |
프로그래머스 - 옹알이(1) (0) | 2023.09.19 |