HDU--3466 -- Proud Merchants -- 01 backpack

Source: Internet
Author: User

HDU--3466 -- Proud Merchants -- 01 backpack

Proud MerchantsTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others) Total Submission (s): 2777 Accepted Submission (s): 1155

Problem DescriptionRecently, iSea went to an existing ent country. for such a long time, it was the most wealthy and powerful kingdom in the world. as a result, the people in this country are still very proud even if their nation hasn't been so wealthy any more.
The merchants were the most typical, each of them only sold exactly one item, the price was Pi, but they wocould refuse to make a trade with you if your money were than Qi, and iSea evaluated every item a value Vi.
If he had M units of money, what's the maximum value iSea cocould get?


InputThere are several test cases in the input.

Each test case begin with two integers N, M (1 ≤ N ≤ 500, 1 ≤ M ≤ 5000), indicating the items 'Number and the initial money.
Then N lines follow, each line contains three numbers Pi, Qi and Vi (1 ≤ Pi ≤ Qi ≤ 100, 1 ≤ Vi ≤ 1000), their meaning is in the description.

The input terminates by end of file marker.


OutputFor each test case, output one integer, indicating maximum value iSea cocould get.


Sample Input
2 1010 15 105 10 53 105 10 53 5 62 7 3

Sample Output
511
Question: Give You N items and M units of money, each item has a price a, the premise of the purchase of funds B, value c, to buy an item, your money must be greater than or equal to B, and the maximum value can be obtained.

This is a prerequisite for a backpack problem, mainly to determine the order of appearance of the item. I said that, like the previous question, I would not resolve the issue to prepare the rhythm of death. I will add it when I understand it.



# Include
  
   
# Include
   
    
# Include
    
     
# Include # define Max (a, B) a> B? A: busing namespace std; struct node {int a, B, c;} s [555]; bool cmp (const node & a, const node & B) {return a. b-a.a
     
      
= S [I]. b; j --) dp [j] = Max (dp [j], dp [j-s [I]. a] + s [I]. c); printf ("% d \ n", dp [m]);} return 0 ;}
     
    
   
  

Summary: Today we have made these two questions: one is a K branch backpack and the other is a prerequisite backpack. These days have slipped away!


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.