Pagini recente » Cod sursa (job #1432566) | Cod sursa (job #1472836) | Cod sursa (job #534701) | Cod sursa (job #1235098) | Cod sursa (job #1140896)
#include <fstream>
#include <iostream>
#include <queue>
using namespace std;
ifstream f("heapuri.in");
ofstream g("heapuri.out");
const int maxn = 200010;
priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > heap;
int n, k;
bool del[maxn];
int main()
{
int x, type;
k = 0;
f >> n;
while(n--)
{
f >> type;
if(type == 1)
{
f >> x;
heap.push(make_pair(x, ++k));
}
else if(type == 2)
{
f >> x;
del[x] = true;
}
else
{
while(del[heap.top().second])
heap.pop();
g << heap.top().first << '\n';
}
}
}