线段树维护一下区间min, max。...qr, v);
if(qr > mid) Min(rs[k], mid + 1, r, ql, qr, v);
}
int QueryMx(int k, int l, int r, int p)..., QueryMx(ls[k], l, mid, p));
else chmax(ans, QueryMx(rs[k], mid + 1, r, p));
return ans;
}
int...QueryMn(int k, int l, int r, int p) {
int ans = mn[k];
if(l == r) return ans;
int mid =...l + r >> 1;
if(p <= mid) chmin(ans, QueryMn(ls[k], l, mid, p));
else chmin(ans, QueryMn(rs[k]