A thief enters a house and have a cloth to collect the items. The cloth has a fix capacity M. Thief can either select an item fully or leave that. Given the items with weight w1,w2,...wn and there values v1,v2,...vn. What is the maximum values he can collect.
For example -
If the capacity of the cloth is 5, the thief can select item#1 and item#2 to make the (3+4=7) profit.
Code
For example -
item number | weight | value |
---|---|---|
1 | 2 | 3 |
2 | 3 | 4 |
3 | 4 | 5 |
4 | 5 | 6 |
If the capacity of the cloth is 5, the thief can select item#1 and item#2 to make the (3+4=7) profit.
Code
No comments:
Post a Comment