Pagini recente » Cod sursa (job #2953521) | Cod sursa (job #1223640) | Cod sursa (job #1237891) | Cod sursa (job #2536554) | Cod sursa (job #2218063)
#include <fstream>
#include <queue>
using namespace std;
ifstream f("heapuri.in");
ofstream g("heapuri.out");
struct heap
{
int val, poz;
bool operator<(const heap &x) const
{
return val > x.val;
}
};
priority_queue <heap> v;
char exista[200005];
int n, 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.pop();
g<<v.top().val<<'\n';
}
}
return 0;
}