Cod sursa(job #2415772)

Utilizator KRAKEN01Sergiu Adrian KRAKEN01 Data 26 aprilie 2019 15:02:23
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.33 kb
#include <vector>
//#include <iostream>
#include <algorithm>
#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 <fstream>
using namespace std;
ifstream cin ("heapuri.in");ofstream cout ("heapuri.out");

int arb[800100];
 const int infinit=1e9;
 void update(int nod , int st , int dr , int pos , int val){
    if (st == dr){
        arb[nod] = val;
        return;}
    int mij = st + dr;
    mij /= 2;
    if (pos <= mij){
        update (nod*2 , st , mij , pos , val);
    }
    else{
        update (nod*2+1 , mij+1 , dr , pos , val);
    }
    arb[nod] = min(arb[nod*2] , arb[nod*2+1]);
}


int main() {
 for (auto &x : arb){
        x = infinit;}
    int n;
    cin>>n;
 int pos = 0;
 for (int i=1; i<=n; i++) {
        int tip;
        cin >> tip;
 if (tip == 1){
            pos++;
            int x;
            cin>>x;
            update (1 , 1 , n , pos , x);
        }
        if (tip == 2){
            int x;
            cin>>x;
            update (1 , 1 , n , x , infinit);
        }
        if (tip == 3){
            cout<<arb[1]<<'\n';
        }
    }

    return 0;
}