import heapq
def solution(operations):
heap = []
answer = []
for i in operations:
op = i.split()
if op[0] == "I":
heapq.heappush(heap, int(op[1]))
else:
if len(heap) == 0:
pass
elif op[1] == "-1":
heapq.heappop(heap)
else:
heap = heapq.nlargest(len(heap), heap)[1:]
heapq.heapify(heap)
if heap:
answer.append(max(heap))
answer.append(min(heap))
else:
answer.append(0)
answer.append(0)
return answer
| 붙은 문자들 속 숫자들은 무조건 넣어야 하고 -1 1에 따라 min max 구분하면 되겠다.
만약 문자가 하나있는 경우에 -1, 1을 만나면 무조건 pop시켜 주기로