Pagini recente » Cod sursa (job #1721252) | Cod sursa (job #2365945) | Cod sursa (job #1983484) | Cod sursa (job #843046) | Cod sursa (job #1086718)
#include <algorithm>
#include <fstream>
#include <vector>
#define Nmax 200999
using namespace std;
ifstream f("heapuri.in");
ofstream g("heapuri.out");
int N,K,poz[Nmax];
vector <int> v;
bool cmp(const int &A,const int &B)
{
return A>B;
}
int main()
{
f>>N;
make_heap (v.begin(),v.end(),cmp);
for(int i=1;i<=N;++i)
{
int tip;
f>>tip;
if(tip==1)
{
int x;
f>>x;
v.push_back(x);
push_heap(v.begin(),v.end());
poz[++K]=x;
}
else
if(tip==2)
{
int x;
f>>x;
pop_heap (v.begin(),v.end());
v.pop_back();
}
else
{
g<<v.front()<<'\n';
}
}
f.close();g.close();
return 0;
}