Cod sursa(job #2717897)

Utilizator ardutgamerAndrei Bancila ardutgamer Data 8 martie 2021 10:02:41
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.65 kb
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <fstream>

using namespace std;

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

const int NMAX = 200005;

multiset<int>st;
int v[NMAX];
int cnt = 0;

int main()
{
	ios_base::sync_with_stdio(false);
	fin.tie(0); fout.tie(0);
	int t;
	fin >> t;
	while (t--)
	{
		int op;
		fin >> op;
		if (op == 1)
		{
			int x;
			fin >> x;
			v[++cnt] = x;
			st.insert(x);
		}
		else if (op == 2)
		{
			int x;
			fin >> x;
			st.erase(st.find(v[x]));
		}
		else
		{
			fout << *(st.begin()) << '\n';
		}
	}
	return 0;
}