acgo题库
  • 首页
  • 题库
  • 题单
  • 竞赛
  • 讨论
  • 排行
  • 团队
  • 备赛专区

    竞赛

    • CSP-J/S
    • 蓝桥杯

    考级

    • GESP
    • CPA
    • 电子学会考级
登录
注册
题目详情题解(0)讨论(0)提交记录(0)
  • 题解

    userId_undefined

    法兰西玫瑰

    倔强青铜
    51阅读
    0回复
    2点赞
  • 多重背包-模板

    userId_undefined

    胡天维

    秩序白银
    17阅读
    0回复
    1点赞
  • 题解

    userId_undefined

    zhouty

    秩序白银
    16阅读
    0回复
    0点赞
  • 点赞!!!

    #include<iostream> using namespace std; long long w[10005],v[10005],s[10005],f[10005],m,n,idx=1; int main(){ cin>>m>>n; for(int i=1;i<=n;i++){ int ww,vv,ss; cin>>ww>>vv>>ss; for(int j=1;j<=ss;j++){ w[idx]=ww; v[idx]=vv; idx++; } } for(int i=1;i<idx;i++){ for(int j=m;j>=w[i];j--){ f[j]=max(f[j],f[j-w[i]]+v[i]); } } cout<<f[m]; return 0; }

    userId_undefined

    htd

    倔强青铜
    16阅读
    0回复
    0点赞
  • 题解

    为何要多开数组

    userId_undefined

    潜龙暗虎

    倔强青铜
    13阅读
    0回复
    0点赞
  • 混合背包的代码也能过

    userId_undefined

    LOVEKlee1314

    倔强青铜
    6阅读
    0回复
    0点赞
  • 最基础题解

    最基础题解:

    userId_undefined

    哲

    倔强青铜
    4阅读
    0回复
    0点赞
  • 单调队列

    #include<bits/stdc++.h> using namespace std; int w,v,c,n,V,l,r,dp[1001],a[1001],b[1001]; void insert(int x,int y,int a,int b) { while(l<=r&&b[r]<=y) r--; r++; a[r]=x; b[r]=y; } int main() { scanf("%d%d",&V,&n); int i,q,d; for(i=1;i<=n;i++) { scanf("%d%d%d",&v,&w,&c); if(!c||V/v<c) c=V/v; for(d=0;d<v;d++) { l=1; r=0; for(q=0;q<=(V-d)/v;q++) { insert(q,dp[qv+d]-qw,a,b); if(a[l]<q-c)l++; dp[qv+d]=b[l]+qw; } } } printf("%d\n",dp[V]); return 0; }

    userId_undefined

    Xylophone

    荣耀黄金
    2阅读
    0回复
    0点赞
  • 。

    userId_undefined

    懒得喷

    倔强青铜
    2阅读
    0回复
    0点赞
  • 题解

    userId_undefined

    嘉陵江的晚风.

    倔强青铜
    2阅读
    0回复
    0点赞
首页