Cod sursa(job #2691728)

Utilizator TheGodFather2131Alexandru Miclea TheGodFather2131 Data 29 decembrie 2020 18:45:41
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.08 kb
//ALEXANDRU MICLEA
 
#include <vector>
#include <algorithm>
#include <string>
#include <string.h>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <time.h>
#include <iomanip>
#include <deque>
#include <math.h>
#include <cmath>
#include <assert.h>
#include <stack>
#include <bitset>
#include <random>
#include <chrono>
#include <assert.h>
 
using namespace std;
using ll = long long;
 
#include <fstream>
//ifstream cin("input.in"); ofstream cout("output.out");
ifstream cin("heapuri.in"); ofstream cout("heapuri.out");
 
//VARIABLES

const int maxn = 200005;
multiset <int> h;

int k = 0, pos[maxn];

//FUNCTIONS



//MAIN
 
int main() {
    
    int n; cin >> n;
    for (int i = 1; i <= n; i++){
        int tip, val; cin >> tip;
        if (tip != 3){
            cin >> val;
        }

        if (tip == 1){
            h.insert(val);
            pos[++k] = val;
        }
        if (tip == 2) h.erase(pos[val]);
        if (tip == 3) cout << *h.begin() << '\n';
    }
    
    return 0;
}