Question: Use python3 Bob has just won a shopping spree at his favorite store, Acme Electronics. Acme has provided Bob with a shopping cart that can

Use python3

Use python3 Bob has just won a shopping spree at his favorite

Bob has just won a shopping spree at his favorite store, Acme Electronics. Acme has provided Bob with a shopping cart that can hold L pounds of items. Bob wants to maximize the total value of items he can place into his shopping cart, without exceeding the weight limit. He can take no more than one of each available item. For example, Bob has a shopping cart that can hold 10 pounds of items, and there are 4 items in the store: 5 4 3 2 10 8 4 8 Bob can maximize the value of his cart by selecting one item of value 10 (weight 8) and one of value 3 (weight 2) for a total of 13. Input: The input consists of a line containing two integers L and N, separated by a space. L is the maximum weight of items that he may place into his shopping cart, and N is the number of types of items in the store. Then N lines follow, each containing two integers P and W separated by a space. P contains the price of the item, and W contains the weight of the item. 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!