Cod sursa(job #2904903)
| Utilizator | Data | 18 mai 2022 16:14:19 | |
|---|---|---|---|
| Problema | Heapuri | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.63 kb |
#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;
}