Pagini recente » Cod sursa (job #1238637) | Cod sursa (job #833541) | Cod sursa (job #832406) | Cod sursa (job #76711) | Cod sursa (job #1320117)
#include<fstream>
#include<queue>
#include<map>
using namespace std;
ifstream fin("heapuri.in");
ofstream fout("heapuri.out");
vector<int> INTRAT;
map<int, bool> inH;
class cmp{
public: bool operator ()(const int &a, const int &b) {
return a>b;
}};
priority_queue<int, vector<int>, cmp> HEAP;
inline void add(int val) {
HEAP.push(val);
INTRAT.push_back(val);
inH[val] = 1;
}
inline void del(int i) {
inH[INTRAT[i-1]] = 0;
}
inline void afis() {
while(!inH[HEAP.top()])
HEAP.pop();
fout<<HEAP.top()<<'\n';
fout.flush();
}
int main() {
int T, type, val;
fin>>T;
while(T--) {
fin>>type;
if(type == 3) {
afis();
continue;
}
fin>>val;
switch(type) {
case 1: add(val);break;
case 2: del(val);break;
}
}
return 0;
}