Pagini recente » Cod sursa (job #2538665) | Cod sursa (job #1378587) | Cod sursa (job #3140123) | Cod sursa (job #277389) | Cod sursa (job #1368491)
#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, time = 0;
in >> N;
while ( N-- )
{
int tip, x;
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();
out << MinHeap.top().val << "\n";
}
}
return 0;
}