Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Description You are a theif sneaking into a house that contains N items. You carry a bag and want to steal some valuable items from
Description You are a theif sneaking into a house that contains N items. You carry a bag and want to steal some valuable items from the house. Unfortunately, your bag can hold at most K kilograms. As a smart theif, you know exactly the value Vi and the weight Wi of each item. Since your bag is not strong enough to carry over the limit of K (the sum of weight Wi you carry must be less then K). What is the highest value you can carry out from this house? Input The first line contains two integers N and K, representing the number of items in the house and how much can the bag hold. Each of the following N lines contain two integers Vi and Wi, describing the value and weight of the i-th item. It is guaranteed that: Os Vi, Wis 10 For test case #1-9:15 NS 20,0 SKS 103 For test case #10:15 NS 100,0 SKS 103 Output Print the most value the thief can get. (you need to print a newline ''n' right following your answer) For the sample test case, we can choose the third item (6,3) and the fifth (5.4) item. The maximum value the thief can get would be 11. Sample Input Download 57 34 53 63 43 54 Sample Output Download 11 Description You are a theif sneaking into a house that contains N items. You carry a bag and want to steal some valuable items from the house. Unfortunately, your bag can hold at most K kilograms. As a smart theif, you know exactly the value Vi and the weight Wi of each item. Since your bag is not strong enough to carry over the limit of K (the sum of weight Wi you carry must be less then K). What is the highest value you can carry out from this house? Input The first line contains two integers N and K, representing the number of items in the house and how much can the bag hold. Each of the following N lines contain two integers Vi and Wi, describing the value and weight of the i-th item. It is guaranteed that: Os Vi, Wis 10 For test case #1-9:15 NS 20,0 SKS 103 For test case #10:15 NS 100,0 SKS 103 Output Print the most value the thief can get. (you need to print a newline ''n' right following your answer) For the sample test case, we can choose the third item (6,3) and the fifth (5.4) item. The maximum value the thief can get would be 11. Sample Input Download 57 34 53 63 43 54 Sample Output Download 11
Step 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