Pagini recente » Borderou de evaluare (job #1513123) | Cod sursa (job #1581909) | Cod sursa (job #3321367) | Cod sursa (job #3305546) | Cod sursa (job #3343926)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("heapuri.in");
ofstream fout("heapuri.out");
struct heapnode{
int val;
int cnt;
bool operator < (const heapnode &other) const{
return val > other.val;
}
};
const int nmax=2e5;
int n;
priority_queue<heapnode> heap;
bool deleted[nmax];
int main()
{
fin >> n;
int c, x, cont=1;
for(int i=0; i<n; i++)
{
fin >> c;
if(c==3)
{
while(deleted[heap.top().cnt])
heap.pop();
fout << heap.top().val << '\n';
}
else
{
fin >> x;
if(c==1)
heap.push({x,cont++});
else
deleted[x]=true;
}
}
return 0;
}