Pagini recente » Cod sursa (job #126794) | Cod sursa (job #3264821) | Cod sursa (job #2786605) | Cod sursa (job #709941) | Cod sursa (job #1985259)
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
using namespace std;
#define fi first
#define se second
typedef long long LL;
typedef long double LD;
const int maxn=100100;
int N,M,t[2*maxn];
void update(int pos, int val){
for (t[pos+=N]=val; pos>1; pos>>=1)
t[pos>>1]=max(t[pos],t[pos^1]);
}
int query(int l, int r){
int res=0;
for (l+=N, r+=N; l<=r; l=(l+1)>>1,r=(r-1)>>1){
if (l&1) res=max(res,t[l]);
if (!(r&1)) res=max(res,t[r]);
}
return res;
}
int main(){
ifstream fin("arbint.in");
ofstream fout("arbint.out");
fin >> N >> M;
int i,l,r,op;
for (i=0; i<N; i++){
int x;
fin >> x;
update(i,x);
}
while (M--){
fin >> op >> l >> r;
if (op==0) fout << query(l-1,r-1) << "\n";
else update(l-1,r);
}
return 0;
}