HDU2602Bone Collector

Bone Collector

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 29685    Accepted Submission(s): 12208

Problem Description

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 ?

Input

The first line contain a integer T , the number of cases.

Followed by T cases , each case three lines , the first line contain two integer N , V, (N <= 1000 , V <= 1000 )representing the number of bones and the volume of his bag. And the second line contain N integers representing the value of each bone. The third
line contain N integers representing the volume of each bone.

Output

One integer per line representing the maximum of the total value (this number will be less than 231).

Sample Input

1
5 10
1 2 3 4 5
5 4 3 2 1

Sample Output

14

简单01背包

#include<iostream>
#include<cstdio>
#include<cmath>
#include<queue>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n,i,j,v;
        scanf("%d%d",&n,&v);
        int dp[1100]={0},c[1100],w[1100];
        for(i=0;i<n;i++)
            scanf("%d",w+i);
        for(i=0;i<n;i++)
            scanf("%d",c+i);
        for(i=0;i<n;i++)
        {
            for(j=v;j>=c[i];j--)
            {
                if(dp[j]<dp[j-c[i]]+w[i])
                {
                    dp[j]=dp[j-c[i]]+w[i];
                }
            }
        }
        printf("%d\n",dp[v]);
    }
    return 0;
}

HDU2602Bone Collector

时间: 2024-08-02 01:49:58

HDU2602Bone Collector的相关文章

HDU2602Bone Collector 简单0-1背包

Bone Collector Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 48618    Accepted Submission(s): 20269 Problem Description Many years ago , in Teddy’s hometown there was a man who was called “Bo

HDU-2602-Bone Collector (最基础DP!!)

Bone Collector Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 31922    Accepted Submission(s): 13138 Problem Description Many years ago , in Teddy's hometown there was a man who was called "Bo

hdu2602Bone Collector ——动态规划(0/1背包问题)

Problem Description 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

hdu2602Bone Collector(01背包)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 01背包 1 #include <iostream> 2 #include<algorithm> 3 #include<cstring> 4 using namespace std; 5 int w[1010]; 6 int val[1010]; 7 int dp[1010]; 8 9 int main() 10 { 11 int t,n,v; 12 cin>&

Bone Collector

Problem Description 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

hduoj 2602Bone Collector

Bone Collector Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 40598    Accepted Submission(s): 16872 Problem Description Many years ago , in Teddy’s hometown there was a man who was called “Bon

Bone Collector(杭电2602)(01背包)

Bone Collector Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 31604    Accepted Submission(s): 13005 Problem Description Many years ago , in Teddy's hometown there was a man who was called "Bo

Java_garbage collector

摘自:http://blog.csdn.net/java2000_wl/article/details/8030172 HotSpot JVM垃圾收集器 上面有7中收集器,分为两块,上面为新生代收集器,下面是老年代收集器.如果两个收集器之间存在连线,就说明它们可以搭配使用. Serial(串行GC)收集器_Serial GC Serial收集器是一个新生代收集器,单线程执行,使用复制算法.它在进行垃圾收集时,必须暂停其他所有的工作线程(用户线程).是Jvm client模式下默认的新生代收集器.

hdu 4336 Card Collector

Card Collector http://acm.hdu.edu.cn/showproblem.php?pid=4336 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Special Judge Problem Description In your childhood, do you crazy for collecting the beautiful cards in