Pagini recente » Cod sursa (job #518285) | Cod sursa (job #879785) | Cod sursa (job #2522175) | Cod sursa (job #1280364) | Cod sursa (job #2695831)
#include <fstream>
#include <queue>
#include <vector>
using namespace std;
ifstream fin("heapuri.in");
ofstream fout("heapuri.out");
const int qmax=200000;
struct cmp{
bool operator()(int x,int y){
return x>y;
}
};
priority_queue <int, vector <int>, cmp> h, hd;
int p[qmax+1], pn;
int main(){
int q;
fin>>q;
for(int i=1;i<=q;i++){
int x;
fin>>x;
if(x==1){
int y;
fin>>y;
pn++;
p[pn]=y;
h.push(y);
}else if(x==2){
int y;
fin>>y;
hd.push(p[y]);
}else{
while(hd.empty()==0&&hd.top()==h.top()){
hd.pop();
h.pop();
}
fout<<h.top()<<"\n";
}
}
return 0;
}