Bone Collector--hdu2602(01背包)
2015-05-04 19:03
387 查看
[align=left]Problem Description[/align]
Many years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like to collect varies of bones , such as dog’s , cow’s , also he went to the grave …
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 ?
View Code
Many years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like to collect varies of bones , such as dog’s , cow’s , also he went to the grave …
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 ?
#include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> using namespace std; #define N 1100 int dp ; int main() { int T,i,j,V,n,v ,w ; scanf("%d",&T); while(T--) { memset(dp,0,sizeof(dp)); scanf("%d%d",&n,&V); for(i=0;i<n;i++) scanf("%d",&v[i]); for(i=0;i<n;i++) scanf("%d",&w[i]); for(i=0;i<n;i++) { for(j=V;j>=w[i];j--) { dp[j]=max(dp[j],dp[j-w[i]]+v[i]); } } printf("%d\n",dp[V]); } return 0; }
View Code
相关文章推荐
- hdu2602 Bone Collector (01背包)
- hdu2602 Bone Collector(01背包问题)
- hdu2602 Bone Collector(01背包)
- HDU2602:Bone Collector(01背包)
- [原]hdu2602 Bone Collector (01背包)
- hdu2602 Bone Collector (01背包)
- HDU2602 Bone Collector(动态规划--01背包)
- 算法提高 01背包 hdu2602 Bone Collector
- HDU2602 Bone Collector 01背包DP 模板题
- hdu2602 bone collector 01背包
- HDU2602:Bone Collector(01背包)
- hdu2602-Bone Collector(01背包模版题)
- [原]hdu2602 Bone Collector (01背包)
- hdu2602 Bone Collector (01背包)
- hdu2602 Bone Collector (01背包)
- HDU2602_Bone Collector【01背包】
- HDU2602 Bone Collector 【01背包】
- hdu2602 Bone Collector (01背包)
- HDU2602 Bone Collector 【01背包】
- hdu2602 Bone Collector 01背包教学题