//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.1f",
        "body": [
            "#include<algorithm>",
            "#include<cstdio>",
            "using namespace std;",
            "const int N=7100005;",
            "int A[N],B[N],C[N],ans[N],h1,t1,h2,t2,h3,t3,s[100005],tmp,re,x,i,n,m,q,u,v,t;",
            "double p;",
            "inline int f(){",
            "    int a=-0xfffffff;",
            "    if(h1<=t1)a=max(a,A[h1]);",
            "    if(h2<=t2)a=max(a,B[h2]);",
            "    if(h3<=t3)a=max(a,C[h3]);",
            "    if(h1<=t1&&a==A[h1])h1++;",
            "    else if(h2<=t2&&a==B[h2])h2++;",
            "    else h3++;",
            "    return a;",
            "}",
            "inline bool cmp(int a,int b){return a>b;}",
            "int main(){",
            "    scanf(\"%d%d%d%d%d%d\",&n,&m,&q,&u,&v,&t);",
            "    p=1.0*u/v;h1=h2=h3=1;",
            "    for(i=1;i<=n;i++)scanf(\"%d\",&s[i]);",
            "    sort(s+1,s+n+1,cmp);",
            "    for(i=1;i<=n;i++)A[++t1]=s[i];",
            "    for(i=1;i<=m;i++){",
            "        x=f();",
            "        x+=tmp;",
            "        if(i%t==0)printf(\"%d \",x);",
            "        re=p*x;",
            "        B[++t2]=re-tmp-q;",
            "        C[++t3]=x-re-tmp-q;",
            "        tmp+=q;",
            "    }",
            "    printf(\"\\n\");",
            "    for(i=h1;i<=t1;i++)ans[++ans[0]]=A[i];",
            "    for(i=h2;i<=t2;i++)ans[++ans[0]]=B[i];",
            "    for(i=h3;i<=t3;i++)ans[++ans[0]]=C[i];",
            "    sort(ans+1,ans+ans[0]+1,cmp);",
            "    for(i=1;i<=ans[0];i++)",
            "        if(i%t==0)printf(\"%d \",ans[i]+tmp);",
            "    return 0;",
            "}",
            ""
        ],
        "description": "插入 单调队列：蚯蚓"
    }
}