Pagini recente » Cod sursa (job #215179) | Cod sursa (job #327334) | Cod sursa (job #2394421) | Cod sursa (job #344122) | Cod sursa (job #2904903)
#include <bits/stdc++.h>
using namespace std;
const int NMAX = 2e5;
bool out[NMAX + 1];
priority_queue <pair<int, int>> pq;
int main() {
ifstream fin( "heapuri.in" );
ofstream fout( "heapuri.out" );
int n, inserted = 0;
fin >> n;
for ( int i = 0; i < n; i ++ ) {
int tip, x;
fin >> tip;
if ( tip == 3 ) {
while ( out[pq.top().second] == 1 ) pq.pop();
fout << -pq.top().first << '\n';
} else if ( tip == 2 ) {
fin >> x;
out[x] = 1;
} else {
fin >> x;
pq.push( { -x, ++inserted } );
}
}
return 0;
}