Pagini recente » moisil_11-12 | Cod sursa (job #1109298) | Cod sursa (job #1518126) | Cod sursa (job #1551604) | Cod sursa (job #2954204)
#include <bits/stdc++.h>
using namespace std;
ifstream f("heapuri.in");
ofstream g("heapuri.out");
const int N = 1e5 + 5;
int c, x, n, k;
priority_queue<pair<int, int>> q;
bitset<N> valid;
int main()
{
f >> n;
for (; n; n--){
f >> c;
if (c == 3){
while(!valid[q.top().second]) q.pop();
g << (-q.top().first) << '\n';
}
else {
f >> x;
if (c == 1){
q.push({-x, ++k});
valid[k] = 1;
}
else valid[x] = 0;
}
}
return 0;
}