Cod sursa(job #2754790)

Utilizator anaop32Oprea Ana-Maria anaop32 Data 26 mai 2021 15:38:49
Problema Arbori de intervale Scor 40
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.72 kb
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream f("arbint.in");
ofstream g("arbint.out");
int n, m, maxim, x, y, op;
vector <int> clasament;
int main(){
    f >> n >> m;
    for (int i = 0; i < n; i++){
        f >> x;
        clasament.push_back(x);
    }

    for (int i = 0; i < m; i++){
        f >>op;
        if (op == 1){
            f >> x >> y;
            clasament[x-1] = y;
        }
        else{
            f >> x >> y;
            maxim = 0;
            for (int j = x - 1; j < y; j++){
                if (clasament[j] > maxim)
                    maxim = clasament[j];
            }
            g << maxim << '\n';
        }
    }
    return 0;
}