Pagini recente » Cod sursa (job #1636717) | Cod sursa (job #246516) | Cod sursa (job #2227474) | Cod sursa (job #1617148) | Cod sursa (job #2218062)
#include <fstream>
#include <queue>
using namespace std;
ifstream f("heapuri.in");
ofstream g("heapuri.out");
struct heap
{
int val, poz;
bool tiperator<(const heap &x) const
{
return val > x.val;
}
};
priority_queue <heap> v;
char exista[200005];
int n, i, tip, x, p;
int main()
{
f >> n;
for (int i = 1; i <= n; i ++ )
{
f >> tip;
if (tip == 1)
{
f >> x;
v.push({x,++p});
}
else
if (tip == 2)
{
f >> x;
exista[x] = 1;
}
else
if (tip == 3)
{
while (!v.empty() && exista[v.top().poz])
v.top();
g << v.top().val << '\n';
}
}
return 0;
}