Pagini recente » Cod sursa (job #2838781) | Cod sursa (job #1471827) | Cod sursa (job #1634691) | Cod sursa (job #3295567) | Cod sursa (job #2702137)
#include <bits/stdc++.h>
using namespace std;
ifstream f("heapuri.in");
ofstream g("heapuri.out");
int n, t, v[200009];
priority_queue<int, vector<int>, greater<int>> pq;
unordered_set<int> mst;
int main()
{
f >> n;
for (int c, x; n; n--)
{
f >> c;
if (c == 1)
{
f >> x;
v[++t] = x;
mst.insert(x);
pq.push(x);
}
else if (c == 2)
{
f >> x;
mst.erase(v[x]);
}
else
{
while (mst.find(pq.top()) == mst.end())
pq.pop();
g << pq.top() << '\n';
}
}
return 0;
}