Pagini recente » Cod sursa (job #471988) | Cod sursa (job #811410) | Cod sursa (job #413172) | Cod sursa (job #2520505) | Cod sursa (job #1368479)
#include <bits/stdc++.h>
using namespace std;
struct Node
{
int val;
int timp;
bool operator < (const Node& N) const
{
return val > N.val;
}
};
priority_queue<Node> MinHeap;
unordered_set<int> Hash;
int main()
{
ifstream in("heapuri.in");
ofstream out("heapuri.out");
int N;
in >> N;
while ( N-- )
{
int tip, x, time = 0;
in >> tip;
if ( tip == 1 )
{
in >> x;
MinHeap.push( {x, ++time} );
}
if ( tip == 2 )
{
in >> x;
Hash.insert(x);
}
if ( tip == 3 )
{
while ( MinHeap.size() && Hash.find(MinHeap.top().timp) != Hash.end() )
MinHeap.pop();
if ( MinHeap.size() )
cout << MinHeap.top().val << "\n";
else
cerr << "Error";
}
}
return 0;
}