zoukankan      html  css  js  c++  java
  • HDU 2602 Bone Collector

    Bone Collector

    Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 7774 Accepted Submission(s): 2884


    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

    Author

    Teddy

    Source

    Recommend

    lcy
     1 #include<stdio.h>
    2 #include<string.h>
    3 #include<stdlib.h>
    4 #define max 1010
    5 struct bone
    6 {
    7 int ve , value ;
    8 }num[max] ;
    9 int T , N , V , Mv[max] ;
    10 int MAX ( int a , int b )
    11 {
    12 return a > b ? a : b ;
    13 }
    14
    15 int main ()
    16 {
    17 scanf ( "%d" , &T ) ;
    18 while ( T -- ) {
    19 scanf ( "%d%d" , &N , &V ) ;
    20 for ( int i = 1 ; i <= N ; i ++ )
    21 scanf ( "%d" , &num[i].value ) ;
    22 for ( int i = 1 ; i <= N ; i ++ )
    23 scanf ( "%d" , &num[i].ve ) ;
    24 for ( int i = 0 ; i <= V ; i ++ )
    25 Mv[i] = 0 ;
    26 for ( int i = 1 ; i <= N ; i ++ )
    27 for ( int j = V ; j >= num[i].ve ; j -- )
    28 Mv[j] = MAX ( Mv[j] , Mv[j - num[i].ve] + num[i].value ) ; // 状态方程
    29 printf ( "%d\n" , Mv[V] ) ;
    30 }
    31 return 0 ;
    32 }

      

  • 相关阅读:
    太tmd恐怖了,一个搞破解的过程分析。
    JQuery爱好者们的福音:jQuery EasyUI 开源插件套装 完全替代ExtJS
    期待5月的灿烂阳光
    2010 2月记
    JQuery 的跨域方法 可跨任意网站
    准备写个ASP.NET MVC 2开发的系列文章
    Win7 访问网络共享文件夹显示空白目录的问题解决
    4月的长沙
    将ASP.NET MVC 2.0 部署在IIS6和IIS7上的教程
    谈谈年底感想
  • 原文地址:https://www.cnblogs.com/jbelial/p/2131060.html
Copyright © 2011-2022 走看看