Pagini recente » Cod sursa (job #2618041) | Cod sursa (job #2746562)
#include <iostream>
#include <vector>
#include <fstream>
#include<bits/stdc++.h>
using namespace std;
void operatie_2( vector < int > &lista, int numar ){
int i = 0;
while( lista[i] != numar ){
i++;
}
lista[i] = lista[ lista.size()-1 ];
lista.pop_back();
}
int main(){
vector < int > numere;
vector < int > lista;
int n;
ifstream fin("heapuri.in");
ofstream fout("heapuri.out");
fin >> n;
for( int i = 0; i < n; i++ ){
int operatie, numar;
fin >> operatie;
if( operatie == 1 ){
fin >> numar;
numere.push_back(numar);
lista.push_back(numar*(-1));
}
if( operatie == 2 ){
fin >> numar;
operatie_2( lista, numere[numar-1]*(-1) );
}
if( operatie == 3 ){
make_heap(lista.begin(), lista.end());
fout << lista.front()*(-1) << endl;
}
}
}