他给的是三维坐标,我给铺开了,变成二维的,三维的不好找转移方程,寻找前置状态比较麻烦 #include <bits/stdc++.h> #define ll long long #define ull unsigned long long using namespace std; struct thing { int w,s; }; thing things[20001]; int n,m,v,c=0,maxs=0,t[501]; int main(int argc, const char * argv[]) { memset(t,0,sizeof t); cin>>n>>v; for(int i=1,j=1;i<=n;++i) { scanf("%d%d%d",&m,&things[j].w,&things[j].s); c+=m; int k=1; for(;k<m;++k) { things[k+j].w=things[j].w,things[k+j].s=things[j].s; } j+=k; } for(int j=1;j<=c;++j) { for(int i=v;i>0;--i) { int k=i-things[j].w; t[i]=(k>=0?max(t[k]+things[j].s,t[i-1]):t[i-1]); maxs=max(maxs,t[i]); } } cout<<maxs; }
点赞 27

相关推荐

点赞 评论 收藏
分享
09-09 06:44
已编辑
浙江大学 深度学习
无敌王八拳:貌似10月线下面?
投递华为技术有限公司等公司10个岗位
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务