https://programmers.co.kr/learn/courses/30/lessons/42628
난이도가 3단계여서 겁먹고 최소힙, 최대힙 두개만들어서 별짓다했는데 이렇게 풀어도 시간초과가 발생하지 않는다..
(테스트케이스가 많이 부족해보인다.)
def solution(operations):
import heapq
heap=[]
for i in operations:
order,data=i.split()
if order=="I":
heapq.heappush(heap,int(data))
elif order=="D" and len(heap)!=0:
if data=="1":
heap.pop(heap.index(max(heap)))
elif data=="-1":
heapq.heappop(heap)
if len(heap)!=0:
return ([max(heap),min(heap)])
else:
return ([0,0])