Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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. 1Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started