QHEAP1

  • + 0 comments

    from heapq import heappush, heappop h= [] p = set()

    data = [input().split(' ') for _ in range(int(input()))] for idx in range(len(data)): records = data[idx] if records[0] == '1': # p.add(records[1],heappush(h, records[1])) p.add(int(records[1])) heappush(h, int(records[1])) elif records[0] == '2': p.discard(int(records[1])) elif records[0] == '3': while h[0] not in p: heappop(h) print(h[0])