Pagini recente » Cod sursa (job #983942) | Cod sursa (job #1602450) | Cod sursa (job #1358626) | Cod sursa (job #778915) | Cod sursa (job #1368495)
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
priority_queue<pp, vector<pp>, greater<pp> > 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().second) != Hash.end() )
MinHeap.pop();
out << MinHeap.top().first << "\n";
}
}
return 0;
}