Pagini recente » Cod sursa (job #952574) | Cod sursa (job #3130246) | Cod sursa (job #1241796) | Cod sursa (job #1819931) | Cod sursa (job #3163608)
#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;
fin >> 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;
}