Pagini recente » Cod sursa (job #2697761) | Cod sursa (job #2346748) | Cod sursa (job #229471) | Cod sursa (job #795626) | Cod sursa (job #2737004)
#include <bits/stdc++.h>
using namespace std;
ifstream f("heapuri.in");
ofstream g("heapuri.out");
int main() {
int order[1001];
int n,j=1;
priority_queue<int> heap;
f>>n;
for(int i=0;i<n;i++)
{
int op,value;
f>>op;
if(op==1)
{
f>>value;
heap.push((-1)*value);
order[j++] = value;
}
else if(op==2)
{
f>>value;
value = order[value];
int removed[1001],k=0;
while(!heap.empty() && heap.top()!=(-1)*value)
{
removed[k++] = heap.top();
heap.pop();
}
heap.pop();
for(int i=0;i<k;i++)
heap.push(removed[i]);
}
else if(op==3)
{
cout<<(-1)*heap.top()<<'\n';
}
}
return 0;
}