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

{
    "Lightning Conductor": {
        "prefix": "acm-5.1分治",
        "body": [
            "#include<algorithm>",
            "#include<cstdio>",
            "#include<cmath>",
            "#define Re register int",
            "using namespace std;",
            "const int N=5e5+3;",
            "int i,j,n,h,t,a[N],Q[N],Poi[N];",
            "double tmp,p[N],sqr[N];",
            "inline void in(Re &x){",
            "    int f=0;x=0;char c=getchar();",
            "    while(c<'0'||c>'9')f|=c=='-',c=getchar();",
            "    while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();",
            "    x=f?-x:x;",
            "}",
            "inline void sakura(Re l,Re r,Re L,Re R){",
            "\tif(l>r)return;",
            "\tRe mid=l+r>>1,j0;double mx=0;",
            "\tfor(Re j=L;j<=mid&&j<=R;++j)",
            "\t\tif((tmp=a[j]+sqr[mid-j])>mx)mx=tmp,j0=j;",
            "\tp[mid]=max(p[mid],mx);",
            "\tsakura(l,mid-1,L,j0),sakura(mid+1,r,j0,R);",
            "}",
            "int main(){",
            "    in(n);",
            "    for(Re i=1;i<=n;++i)in(a[i]),sqr[i]=sqrt(i);",
            "    sakura(1,n,1,n);",
            "    for(Re i=1;i<n-i+1;++i)swap(a[i],a[n-i+1]),swap(p[i],p[n-i+1]);",
            "    sakura(1,n,1,n);",
            "    for(Re i=n;i;--i)printf(\"%d\\n\",(int)ceil(p[i])-a[i]);",
            "}",
            ""
        ],
        "description": "插入 Lightning Conductor"
    }
}