//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.2二进制优化",
        "body": [
            "#include<algorithm>",
            "#include<cstring>",
            "#include<cstdio>",
            "#define Re register int",
            "using namespace std;",
            "const int N=103,M=4e4+3;",
            "int n,m,x,y,z,V,ans,v[N*17],w[N*17],dp[M];",
            "inline void in(Re &x){",
            "\tRe fu=0;x=0;char ch=getchar();",
            "\twhile(ch<'0'||ch>'9')fu|=ch=='-',ch=getchar();",
            "\twhile(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();",
            "\tx=fu?-x:x;",
            "}",
            "int main(){",
            "\tin(m),in(V);",
            "\tmemset(dp,-127,sizeof(dp));",
            "\tdp[0]=0;",
            "\twhile(m--){",
            "\t\tin(x),in(y),in(z);Re p=1;",
            "\t\twhile(z>=p)v[++n]=y*p,w[n]=x*p,z-=p,p<<=1;",
            "\t\tif(z)v[++n]=y*z,w[n]=x*z;",
            "\t}",
            "\tfor(Re i=1;i<=n;++i)",
            "\t\tfor(Re j=V;j>=v[i];--j)\t",
            "\t\t\tdp[j]=max(dp[j],dp[j-v[i]]+w[i]);",
            "\tfor(Re i=0;i<=V;++i)ans=max(ans,dp[i]);",
            "\tprintf(\"%d\\n\",ans);",
            "}",
            ""
        ],
        "description": "插入 多重背包  (宝物筛选)"
    }
}