Pagini recente » Cod sursa (job #399195) | Cod sursa (job #2248807) | Cod sursa (job #894182) | Cod sursa (job #2311686) | Cod sursa (job #3199961)
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("heapuri.in");
ofstream fout ("heapuri.out");
const int NMAX=200005;
priority_queue <int,vector<int>,greater<int>> pq1, pq2;
int n, nr, poz[200005];
void afis () {
while (pq2.size()>0 && pq1.top()==pq2.top()) {
pq1.pop();
pq2.pop();
}
fout << pq1.top() << '\n';
}
void add (int x) {
pq1.push(x);
poz[++nr]=x;
}
int main() {
fin >> n;
for (int i=1; i<=n; i++) {
int c;
fin >> c;
if (c==3)
afis();
else {
int a;
fin >> a;
if (c==2)
add(a);
else
pq2.push(poz[a]);
}
}
return 0;
}