Pagini recente » Cod sursa (job #2928821) | Cod sursa (job #1898562) | Cod sursa (job #1007299) | Cod sursa (job #1752176) | Cod sursa (job #3124206)
import heapq
f = open('heapuri.in')
g = open('heapuri.out', 'w')
heap = []
order = []
heapq.heapify(heap)
n = int(f.readline())
for _ in range(n):
cm = f.readline().split()
if cm[0] == '1':
x = int(cm[1])
heapq.heappush(heap, x)
order.append(x)
if cm[0] == '2':
ind = int(cm[1])
ind -= 1
x = order[ind]
heap.remove(x)
heapq.heapify(heap)
if cm[0] == '3':
g.write(str(heap[0]) + '\n')
f.close()
g.close()