HDU 3033 I love sneakers! (01 backpack + reverse grouping backpack)

Source: Internet
Author: User


N, m, and k indicate that there are n pairs of k kinds of shoes, and you have m capacity;


Each pair of shoes has capacity p and value v. If you want to buy all k types of shoes, the maximum value of the shoes can be bought if the capacity is m;


Each pair of shoes can only be bought once (01 backpack). Each type of shoes must have at least one (group backpack: each group can have only one.


Note initialization !!!


# Include
 
  
# Include
  
   
# Include
   
    
# Include
    
     
# Include
     # Include
      
        # Include
       
         # Include
        
          # Include
         
           # Include
          
            Using namespace std; # define INF 1e8 # define eps 1e-8 # define LL long # define maxn 127 # define PI acos (-1.0) struct node {int v, p ;} f [11] [10005]; int main () {int n, m, k; int dp [11] [10005]; while (~ Scanf ("% d", & n, & m, & k) {int I, j; int a, B, c; int kao [15]; memset (kao, 0, sizeof (kao); memset (f, 0, sizeof (f); for (I = 0; I
           
             = F [I] [h]. p; j --) {if (dp [I] [j-f [I] [h]. p]! =-1) // The dp [I] [j] = max (dp [I] [j], dp [I] [j-f [I] [h]. p] + f [I] [h]. v); if (dp [I-1] [j-f [I] [h]. p]! =-1) // The dp [I] [j] = max (dp [I] [j], dp [I-1] [j-f [I] [h]. p] + f [I] [h]. v) ;}} if (dp [k] [m] =-1) printf ("Impossible \ n"); else printf ("% d \ n ", dp [k] [m]);} return 0;}/* 5 10 31 4 62 5 73 4 991 55 772 44 66 */
           
          
         
        
       
      
    
   
  
 


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.