Cod sursa(job #2691730)

Utilizator TheGodFather2131Alexandru Miclea TheGodFather2131 Data 29 decembrie 2020 18:51:50
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.45 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;
const int inf = 1e9;
int v[4 * maxn];
int k;

//FUNCTIONS

void update (int nod, int st, int dr, int pos, int val){
    if (st == dr){
        v[nod] = val;
        return;
    }

    int mid = (st + dr) / 2;

    if (pos <= mid)
        update(nod * 2, st, mid, pos, val);
    else
        update(nod * 2 + 1, mid + 1, dr, pos, val);

    v[nod] = min (v[nod * 2], v[nod * 2 + 1]);
}

//MAIN
 
int main() {

    for (auto& x : v){
        x = inf;
    }
    
    int n; cin >> n;
    for (int i = 1; i <= n; i++){
        int tip, val; cin >> tip;
        if (tip != 3){
            cin >> val;
        }

        if (tip == 1){
            update(1, 1, n, ++k, val);
        }
        if (tip == 2) update(1, 1, n, val, inf);
        if (tip == 3) cout << v[1] << '\n';
    }
    
    return 0;
}