//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 的格式要求是 "插入 [该代码片段的中文名]"

{
    "滑动窗口": {
        "prefix": "acm-2.1数组维护单调队列",
        "body": [
            "#include<algorithm>",
            "#include<cstdio>",
            "const int N=1e6+5;",
            "int n,k,i,h,t,a[N],Q[N],D[N];",
            "int main(){",
            "    scanf(\"%d%d\",&n,&k);",
            "    for(i=1;i<=n;i++){",
            "        scanf(\"%d\",&a[i]);",
            "        while(h<=t&&Q[t]>=a[i])t--;Q[++t]=a[i],D[t]=i;",
            "        while(h<t&&D[h]+k-1<i)h++;",
            "        if(i>=k)printf(\"%d \",Q[h]);",
            "    }",
            "    printf(\"\\n\");h=t=0;",
            "    for(i=1;i<=n;i++){",
            "        while(h<=t&&Q[t]<=a[i])t--;Q[++t]=a[i],D[t]=i;",
            "        while(h<t&&D[h]+k-1<i)h++;",
            "        if(i>=k)printf(\"%d \",Q[h]);",
            "    }",
            "}",
            ""
        ],
        "description": "插入 滑动窗口"
    }
}