Pagini recente » Cod sursa (job #2686820) | Cod sursa (job #3176149) | Cod sursa (job #1119382) | Cod sursa (job #1919317) | Cod sursa (job #2859686)
#include <fstream>
#include <queue>
using namespace std;
ifstream fin ("heapuri.in");
ofstream fout ("heapuri.out");
int n, nr_elem, v[250005], op;
bool used[250005];
long long k;
struct min_heap
{
int ind;
inline bool operator < (const min_heap &other) const
{
return v[ind] > v[other.ind];
}
};
priority_queue <min_heap> heap;
int main()
{
fin>>n;
while(n--)
{
fin>>op;
if(op==1)
{
fin>>k;
v[++nr_elem]=k;
used[nr_elem]=1;
heap.push({nr_elem});
}
if(op==2)
{
fin>>k;
used[k]=0;
}
if(op==3)
{
while(!used[heap.top().ind])
heap.pop();
fout<<v[heap.top().ind]<<'\n';
}
}
return 0;
}