Cod sursa(job #3235897)

Utilizator Cezar2009Cezar Mihai Titihazan Cezar2009 Data 23 iunie 2024 21:57:35
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.86 kb
//https://infoarena.ro/problema/heapuri
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("fast-math")
//#pragma GCC optimize ("unroll-loops")
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <map>
using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, i, c, x;
	priority_queue <int,vector<int>,greater<int>> pq;
	vector <int> v;
	map <int, bool> map;
	fin >> n;
	for (i = 1; i <= n; ++i)
	{
		fin >> c;
		if (c == 1)
		{
			fin >> x;
			pq.push(x);
			v.push_back(x);
		}
		else if (c == 2)
		{
			fin >> x;
			map[v[x - 1]] = true;
		}
		else //if (c == 3);
		{
			while (map[pq.top()])
			{
				map[pq.top()] = false;
				pq.pop();
			}
			fout << pq.top() << "\n";
		}
	}

	return 0;
}