Pagini recente » Cod sursa (job #1597122) | Cod sursa (job #381533) | Cod sursa (job #2562433) | Cod sursa (job #1077993) | Cod sursa (job #1610958)
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
ifstream fin ("heapuri.in");
ofstream fout ("heapuri.out");
const int nmax = 200005;
vector <int> heap;
int ord[nmax], lg, v[nmax];
inline bool cmp (const int &x, const int &y)
{
return x > y;
}
int main()
{
ios_base::sync_with_stdio(false);
vector <int> :: iterator it;
int n, op, x, i;
fin >> n;
for(i=1; i<=n; i++)
{
fin >> op;
if(op==1)
{
fin >> x;
ord[++lg]=x;
heap.push_back(x);
push_heap(heap.begin(), heap.end(), cmp);
}
if(op==2)
{
fin >> x;
it=find(heap.begin(), heap.end(), ord[x]);
heap.erase(it);
make_heap(heap.begin(), heap.end(), cmp);
}
if(op==3) fout << heap[0] << "\n";
}
fin.close();
fout.close();
return 0;
}