Cod sursa(job #169394)
Utilizator | Data | 1 aprilie 2008 17:45:20 | |
---|---|---|---|
Problema | Arbori de intervale | Scor | 40 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.48 kb |
#include<cstdio>
using namespace std;
int main(){
freopen("arbint.in", "r", stdin);
freopen("arbint.out", "w", stdout);
int m, n, *v;
scanf("%d%d", &n, &m);
v = new int[n];
for(int i = 0; i < n; i++)
scanf("%d", &v[i]);
for(int i = 0, o, x, y; i < m; i++){
scanf("%d%d%d", &o, &x, &y);
if(o == 0){
int max = 0;
for(int j = x - 1; j < y; j++)
if(v[j] > max) max = v[j];
printf("%d\n", max);
}
if(o == 1)
v[x-1] = y;
}
}