// File Name: hdu1754.cpp // Author: bo_jwolf // Created Time: friday, August 16, 2013 # include <vector> # include <list> # include <map> # include <set> # include <deque> # include <stack> # include <bitset> # include <algorithm> # include <functional> # include <numeric> # include <utility> # include <sstream> # include <iostream> # include <iomanip> # include <cstdio> # include <cmath> # include <cstdlib> # include <cstring> # I Nclude <ctime> using namespace std; # define lson l, mid, rt <1 # define rson mid + 1, r, rt <1 | 1 const int maxn = 200005; // int sum [maxn <2]; struct node {int Max;} tree [maxn <2]; void PushUp (int rt) {tree [rt]. max = max (tree [rt <1]. max, tree [(rt <1 | 1)]. max);} void build (int l, int r, int rt) {if (l = r) {scanf ("% d", & tree [rt]. max); return ;} Int mid = (l + r)> 1; build (lson); build (rson); PushUp (rt);} void update (int p, int add, int l, int r, int rt) {if (l = r) {tree [rt]. max = add; return;} int mid = (l + r)> 1; if (p <= mid) update (p, add, lson); else update (p, add, rson); PushUp (rt);} int query (int L, int R, int l, int r, int rt) {if (L <= l & r <= R) {return tree [rt]. max ;} Int mid = (l + r)> 1; int ret = 0; if (L <= mid) ret = max (ret, query (L, R, lson); if (R> mid) ret = max (ret, query (L, R, rson); return ret;} int main () {int T, n, m; while (scanf ("% d", & n, & m )! = EOF) {build (1, n, 1); char op [10]; while (m --) {scanf ("% s", op); int a, B; scanf ("% d", & a, & B); if (op [0] = 'q') printf ("% d \ n ", query (a, B, 1, n, 1); else update (a, B, 1, n, 1) ;}} return 0 ;}