/ ALGORITHM

프로그래머스 - 이중우선순위큐

image-20230126160437508

from heapq import heappush, heappop, nlargest

def solution(operations):
    heap = []
    
    for i in operations:
        if i[0]=='I':
            heappush(heap,int(i[2:]))
            
        elif i=="D -1" and heap:
            heappop(heap)
            
        elif i=="D 1" and heap:
            heap.remove(nlargest(1,heap)[0])
            
    if not heap:
        return [0,0]
    else:
        return [max(heap),min(heap)]