Cod sursa(job #2906465)

Utilizator alex_bb8Banilean Alexandru-Ioan alex_bb8 Data 26 mai 2022 09:07:42
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.54 kb
#include <bits/stdc++.h>

using namespace std;

ifstream f("heapuri.in");
ofstream g("heapuri.out");

multiset <int> M;
const int NMAX = 200002;
int order[NMAX];

int main(){

	int n, nr_of_val = 0;

	f >> n;

	for(int i = 1; i <= n; ++i){
		int x, value;

		f >> x;

		if(x == 1){
			f >> value;
			order[++nr_of_val] = value;
			M.insert(value);
		}
		else if(x == 2){
			f >> value;
			M.erase(order[value]);
		}
		else if(x == 3){
			g << *M.begin() << '\n';
		}

	}

	f.close();
	g.close();

	return 0;
}