Pagini recente » Cod sursa (job #1643672) | Cod sursa (job #1276605) | Cod sursa (job #1386647) | Cod sursa (job #4827) | Cod sursa (job #3128774)
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()