Cod sursa(job #3246693)
| Utilizator | Data | 4 octombrie 2024 08:00:36 | |
|---|---|---|---|
| Problema | Heapuri | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.68 kb |
#include <fstream>
#include <vector>
#include <queue>
#include <map>
using namespace std;
ifstream f("heapuri.in");
ofstream g("heapuri.out");
int q;
vector<int> add;
map<int, int> fr;
priority_queue<int> H;
int main()
{
f >> q;
for(int i = 1; i <= q; i ++)
{
int tip; f >> tip;
if(tip == 1){
int x; f >> x;
H.push(-x); add.push_back(x);
}
else if(tip == 2){
int x; f >> x;
fr[add[x - 1]] = 1;
}
else{
while(!H.empty() && fr[-H.top()])
H.pop();
g << -H.top() << '\n';
}
}
return 0;
}
