Bone Collector
Time Limit : 2000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 4 Accepted Submission(s) : 3
The bone collector had a big bag with a volume of V ,and along his trip of collecting there are a lot of bones , obviously , different bone has different value and different volume, now given the each bone’s value along his trip , can you calculate out the maximum of the total value the bone collector can get ?

1 5 10 1 2 3 4 5 5 4 3 2 1
14
题意:
有5个物品 背包容量就是10
体积 5 4 3 2 1
价值 1 2 3 4 5
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
int a[10000],b[10000];
int dp[10000];
int main()
{
int n;
scanf("%d",&n);
while(n--)
{
int m,v,i,j;
scanf("%d%d",&m,&v);
for(i=0;i<m;i++)
scanf("%d",&a[i]);
for(i=0;i<m;i++)
scanf("%d",&b[i]);
memset(dp,0,sizeof(dp));
for(i=0;i<m;i++)//01背包的模板
{
for(j=v;j>=b[i];j--)
{
dp[j]=max(dp[j-b[i]]+a[i],dp[j]);
}
}
printf("%d\n",dp[v]);
}
return 0;
}
本文深入探讨了游戏开发领域的核心技术,包括游戏引擎、动画、3D空间视频等,旨在为开发者提供全面的游戏开发知识和实践经验。
&spm=1001.2101.3001.5002&articleId=51350620&d=1&t=3&u=5e1fe2c5d99047e198635774ab6119db)
355

被折叠的 条评论
为什么被折叠?



