//Place your snippets for cpp here. Each snippet is defined under a snippet name and has a prefix, body and 
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the 
// same ids are connected.
// prefix 的格式要求是 acm-[一级标题编号].[二级标题编号][该代码片段的英文简称]
// description 的格式要求是 "插入 [该代码片段的中文名]"

{
    "单点修改 ，区间查询 (Max)": {
        "prefix": "acm-2.5取Max",
        "body": [
            "#include<cstdio>",
            "#define LL long long",
            "#define Re register int",
            "const int N=1e5+3;",
            "int n,x,y,T,A[N];",
            "inline void in(Re &x){",
            "    int f=0;x=0;char ch=getchar();",
            "    while(ch<'0'||ch>'9')f|=ch=='-',ch=getchar();",
            "    while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();",
            "    x=f?-x:x;",
            "}",
            "inline int max(Re a,Re b){return a>b?a:b;}",
            "struct BIT{",
            "    int C[N];",
            "    inline void add(Re x,Re v){while(x<=n)C[x]=max(C[x],v),x+=x&-x;}",
            "    inline int ask(Re l,Re r){",
            "        Re ans=0;",
            "        while(l<=r){",
            "            while(r-(r&-r)>=l)ans=max(ans,C[r]),r-=r&-r;",
            "            ans=max(ans,A[r--]);",
            "        }",
            "        return ans;",
            "    }",
            "}TR;",
            "int main(){",
            "    in(n),in(T);",
            "    for(Re i=1;i<=n;++i)in(A[i]),TR.add(i,A[i]);",
            "    while(T--)in(x),in(y),printf(\"%d\\n\",TR.ask(x,y));",
            "}",
            ""
        ],
        "description": "插入 单点修改 ，区间查询 (Max)"
    }
}