Cod sursa(job #2750091)
Utilizator | Data | 9 mai 2021 22:01:55 | |
---|---|---|---|
Problema | Heapuri | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.72 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("heapuri.in");
ofstream fout("heapuri.out");
priority_queue <pair <int,int> ,vector <pair <int,int>>,greater <pair <int,int>>> h;
int n,t,x;
bitset <200005> elim;
int main()
{
fin>>n;
int i;
int cnt=0;
for(i=1; i<=n; i++)
{
fin>>t;
if(t==1)
{
fin>>x;
cnt++;
h.push(make_pair(x,cnt));
}
else if(t==2)
{
fin>>x;
elim[x]=1;
}
else
{
while(!h.empty() && elim[h.top().second])
h.pop();
fout<<h.top().first<<"\n";
}
}
return 0;
}