12694 - 電機資結 2020 HW0 Steal the most Value   

Description

■ You are a thief sneaking into a house that contain N-items with a bag that can hold K-kilograms.
■ Each item contains its own value(Vi) and weight(Wi).
■ Since your bag is not strong enough to carry over the limit of K(the sum of weight W you carry must be less than K).
■ What is the highest value you can carry out from this house?

Input

■ The first line contains two integers N(the number of items in the house) and K(how much can the bag hold).
■ Each of the following N lines contains two integers Vi and Wi, which describe the value and weight of i-th item, respectively

Output

■ Print the most value the thief can get.
■ P.S. You don’t need to print newline in the end!

Sample Input  Download

Sample Output  Download

Tags




Discuss