Cod sursa(job #2668794)
| Utilizator | Data | 5 noiembrie 2020 13:45:55 | |
|---|---|---|---|
| Problema | Heapuri | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.71 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("heapuri.in");
ofstream g("heapuri.out");
priority_queue < pair < int , int > , vector < pair < int , int > > , greater < pair < int , int > > > pq;
int n;
bool fr[200005];
int c,x;
int ord;
int main()
{
f >> n;
for (int i=1;i<=n;i++) {
f >> c;
if (c==1) {
f >> x;
ord++;
pq.push(make_pair(x,ord));
}
else if (c==2) {
f >> x;
fr[x]=1;
}
else if (c==3) {
while (fr[pq.top().second]==1) {
pq.pop();
}
g << pq.top().first << '\n';
}
}
return 0;
}
