Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago