Pagini recente » Cod sursa (job #1439433) | Cod sursa (job #3279255) | Cod sursa (job #732173) | Cod sursa (job #1309191) | Cod sursa (job #3235897)
//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;
}