Pagini recente » Cod sursa (job #58412) | Cod sursa (job #2672428) | Cod sursa (job #2793851) | Cod sursa (job #2936754) | Cod sursa (job #3301378)
#include <iostream>
#include <fstream>
#include <unordered_map>
#include <queue>
#include <vector>
using namespace std;
ifstream fin("heapuri.in");
ofstream fout("heapuri.out");
int n,type,x;
priority_queue <int, vector<int>, greater<int>> pq;
unordered_map <int,int> f;
vector <int> v;
int main()
{
fin>>n;
while (n--)
{
fin>>type;
if (type==1)
{
fin>>x;
pq.push(x);
v.push_back(x);
}
else
if (type==2)
{
fin>>x;
f[v[x-1]]++;
}
else
{
while (!pq.empty() && f[pq.top()]>0)
{
f[pq.top()]--;
pq.pop();
}
if (!pq.empty())
fout<<pq.top()<<"\n";
}
}
return 0;
}