Pagini recente » Cod sursa (job #2550204) | Cod sursa (job #2901792) | Cod sursa (job #2328968) | Cod sursa (job #53874) | Cod sursa (job #2734828)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("heapuri.in");
ofstream gout("heapuri.out");
priority_queue <pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> heap;
int n, op, x, index_push = 1;
int main()
{
fin >> n;
for (int t = 1 ; t <= n; ++t)
{
fin >> op;
switch(op)
{
case 1:
{
fin >> x;
heap.push({x, index_push});
++index_push;
break;
}
case 2:
{
fin >> x;
priority_queue <pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> dummy;
while (!heap.empty() && heap.top().second != x)
{
dummy.push(heap.top());
heap.pop();
}
heap.pop();
while (!heap.empty())
{
dummy.push(heap.top());
heap.pop();
}
heap = dummy;
break;
}
case 3:
{
gout << heap.top().first << '\n';
break;
}
}
}
return 0;
}