Pagini recente » Cod sursa (job #2064374) | Cod sursa (job #2624416) | Cod sursa (job #2075532) | Cod sursa (job #2366947) | Cod sursa (job #3163607)
#include <iostream>
#include <fstream>
#include <queue>
using namespace std;
ifstream fin ( "heapuri.in" );
ofstream fout ( "heapuri.out" );
priority_queue <int, vector<int>, greater <int>> q, qDelete;
vector <int> poz(3e5);
int main() {
int t, x, cer, n = 1;
cin >> t;
for ( int i = 0; i < t; i++ ) {
fin >> cer;
if ( cer == 1 ) {
fin >> x;
poz[n] = x;
q.push (x);
n++;
}
else if ( cer == 2 ) {
fin >> x;
qDelete.push (poz[x]);
}
else {
while ( qDelete.size() != 0 && q.top() == qDelete.top() ) {
qDelete.pop();
q.pop();
}
fout << q.top() << "\n";
}
}
return 0;
}