Pagini recente » Cod sursa (job #1604898) | Cod sursa (job #2960614) | Cod sursa (job #82390) | Cod sursa (job #1292112) | Cod sursa (job #2101024)
#include <fstream>
#include <queue>
using namespace std;
ifstream f("heapuri.in");
ofstream g("heapuri.out");
struct heap
{
int valoare, pozitie;
bool operator<(const heap &x) const
{
return valoare > x.valoare;
}
};
priority_queue <heap> v;
char exista[200005];
int N,i,op,x,p=0;
int main()
{
f>>N;
for (i=1 ; i<=N ; ++i)
{
f>>op;
if (op==1)
{
f>>x;
v.push({x,++p});
}
else
if (op==2)
{
f>>x;
exista[x]=1;
}
else
if (op==3)
{
while (!v.empty()&&exista[v.top().pozitie])
v.pop();
g<<v.top().valoare<<'\n';
}
}
return 0;
}