Pagini recente » Cod sursa (job #1558634) | Cod sursa (job #1977729) | Cod sursa (job #1348453) | Profil Markus243 | Cod sursa (job #420235)
Cod sursa(job #420235)
#include<set>
#include<algorithm>
#include<cstdio>
#include<fstream>
using namespace std;
struct comp{
bool operator()(long i,long j){
return i<j;
}
};
multiset<long,comp>heap;
//multiset<long>heap;
long N,pos[200005]={0};
//1:insert 2:delete 3:min
int main(){
//freopen("heapuri.in","r",stdin);
//freopen("heapuri.out","w",stdout);
ifstream fin("heapuri.in");
ofstream fout("heapuri.out");
long t,k=0,x;
//scanf("%d",&N);
fin>>N;
for(long i=1;i<=N;i++){
//scanf("%ld",&t);
fin>>t;
if(t==1){
//scanf("%ld",&x);
fin>>x;
heap.insert(x);
pos[++k]=x;
}
if(t==2){
//scanf("%ld",&x);
fin>>x;
heap.erase(pos[x]);
}
if(t==3){
//printf("%ld\n",*heap.upper_bound(0));
fout<<*heap.upper_bound(0);
}
}
return 0;}