Cod sursa(job #1384329)
| Utilizator | Data | 11 martie 2015 00:22:53 | |
|---|---|---|---|
| Problema | Heapuri | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.62 kb |
#include <fstream>
#include <queue>
using namespace std;
const int MAXN = 200010;
int main() {
ifstream cin("heapuri.in");
ofstream cout("heapuri.out");
int n, tip, x, k = 0;
bool sters[MAXN];
priority_queue<pair<int, int> > q;
cin >> n;
while (n--) {
cin >> tip;
if (tip == 1) {
cin >> x;
q.push(make_pair(-x, ++k));
} else if (tip == 2) {
cin >> x;
sters[x] = true;
} else if (tip == 3) {
while (sters[q.top().second])
q.pop();
cout << -q.top().first << '\n';
}
}
}
