Pagini recente » Cod sursa (job #843162) | Cod sursa (job #2887808) | Cod sursa (job #1850948) | Cod sursa (job #2002539) | Cod sursa (job #2890444)
from heapq import heapify,heappop,heappush
heap=[]
heapify(heap)
f=open("heapuri.in")
n=int(f.readline())
ls=[]
for i in range(n):
linie=[int(x) for x in f.readline().split()]
if linie[0]==1:
heappush(heap,linie[1])
ls.append(linie[1])
elif linie[0]==2:
newls=[]
x=heappop(heap)
while x!=ls[linie[1]-1]:
newls.append(x)
x=heappop(heap)
for x in newls:
heappush(heap,x)
else:
print(heap[0])