Cod sursa(job #1881280)
| Utilizator | Data | 16 februarie 2017 12:32:38 | |
|---|---|---|---|
| Problema | Heapuri | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.63 kb |
#include <bits/stdc++.h>
using namespace std;
int main()
{
ifstream f("heapuri.in");
ofstream g("heapuri.out");
int n;
f >> n;
priority_queue<int, vector<int>, greater<int>> p, q;
vector<int> history;
for(int t, x; n; --n){
f >> t;
if(t == 1){
f >> x;
p.push(x);
history.push_back(x); }
else if(t == 2){
f >> x;
q.push(history[x-1]); }
else{
while(!p.empty() && !q.empty() && p.top() == q.top())
p.pop(), q.pop();
g << p.top() << '\n'; } }
return 0; }
