Cod sursa(job #2630224)

Utilizator KillHorizon23Orban Robert KillHorizon23 Data 24 iunie 2020 19:17:12
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.54 kb
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ifstream fin("heapuri.in");
ofstream fout("heapuri.out");

int n, x, op;
vector<int> f;
set<int> s;
set<int> :: iterator it;

int main()
{
	ios::sync_with_stdio(false);
	fin.tie(0);
	
	fin >> n;
	for (int i = 1; i <= n; ++i)
	{
		fin >> op;
		
		if (op == 1)
		{
			fin >> x;
			s.insert(x), f.push_back(x);
		}
		else if (op == 2)
		{
			fin >> x;
			x = f[x - 1], s.erase(x);
		}
		else
			it = s.begin(), fout << *it << "\n";
	}
	return 0;
}