//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-5.2kth_knapsack",
        "body": [
            "#include<algorithm>",
            "#include<cstring>",
            "#include<cstdio>",
            "int ans,T,n,i,j,k,K,a,b,t,re[45],v[210],w[210],f[5010][45];",
            "int main(){",
            "    scanf(\"%d%d%d\",&K,&T,&n);",
            "    memset(f,-127,sizeof(f));f[0][1]=0;",
            "    for(i=1;i<=n;i++)",
            "        scanf(\"%d%d\",&v[i],&w[i]);",
            "    for(i=1;i<=n;i++)",
            "        for(j=T;j>=v[i];j--){",
            "            a=b=1,t=0;",
            "            while(t<=K){",
            "                if(f[j][a]>=f[j-v[i]][b]+w[i])re[++t]=f[j][a++];",
            "                else re[++t]=f[j-v[i]][b++]+w[i];",
            "            }",
            "            for(k=1;k<=K;k++)f[j][k]=re[k];",
            "        }",
            "    for(i=1;i<=K;i++)ans+=f[T][i];",
            "    printf(\"%d\",ans);",
            "    return 0;",
            "}",
            ""
        ],
        "description": "插入 多人背包"
    }
}