Cod sursa(job #2918035)

Utilizator andrei_C1Andrei Chertes andrei_C1 Data 9 august 2022 13:38:43
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.68 kb
#include <bits/stdc++.h>
#include <ext/pb_ds/priority_queue.hpp>

using namespace std;

ifstream fin("heapuri.in");
ofstream fout("heapuri.out");	

const int INF = 1e9;

int n;
__gnu_pbds :: priority_queue<int, greater<int>, __gnu_pbds :: pairing_heap_tag> pq;
vector<__gnu_pbds :: priority_queue<int, greater<int>, __gnu_pbds :: pairing_heap_tag> :: point_iterator> history;

int main() {
	fin >> n;

	for(int i = 1; i <= n; i++) {
		int task;
		fin >> task;

		if(task == 1) {
			int x;
			fin >> x;

			history.push_back(pq.push(x));
		} else if(task == 2) {
			int x;
			fin >> x;

			x--;

			pq.modify(history[x], -INF);
			pq.pop();
		} else {
			fout << pq.top() << '\n';
		}
	}
	return 0;
}