Pagini recente » Cod sursa (job #1584801) | Cod sursa (job #2120709) | Cod sursa (job #2627767) | Cod sursa (job #2629676) | Cod sursa (job #2374379)
#include <fstream>
#include <queue>
using namespace std;
ifstream fin("heapuri.in");
ofstream fout("heapuri.out");
int n, cod, x, c;
bool ok[200002];
struct str{
int x, pos;
bool operator <(const str &other)const
{
return x>other.x;
}
};
priority_queue<str>H;
int main()
{
fin>>n;
for(int i=1; i<=n; i++)
{
fin>>cod;
if(cod==1)
{
fin>>x;
c++;
ok[c]=1;
H.push({x,c});
}
else if(cod==2)
{
fin>>x;
ok[x]=0;
while(ok[H.top().pos]==0)
{
H.pop();
}
}
else
{
fout<<H.top().x<<'\n';
}
}
}