Pagini recente » Cod sursa (job #287145) | Cod sursa (job #2842172) | Cod sursa (job #1892999) | Cod sursa (job #2328573) | Cod sursa (job #866881)
Cod sursa(job #866881)
#include <fstream>
#include <algorithm>
#include <vector>
using namespace std;
int n,cod,x,aux;
int V[200000];
ifstream f("heapuri.in");
ofstream g("heapuri.out");
int main(){
f >> n;
int k=0,j;
for(int i=1;i<=n;i++){
f >> cod;
if(cod!=3){
if(cod == 1){
f >> x;
V[k] = x;
k++;
push_heap(V,V+k);
}
if(cod == 2) {
f >> x;
for(j=0;j<k;j++)
if(V[j] == x){
aux = j;
break;
}
for(int z=aux;z<k-1;z++)
V[z] = V[z+1];
k--;
}
}
else{
sort_heap(V,V+k);
g << V[0] << '\n';
}
}
f.close();
g.close();
return 0;
}