#K33682. Maximum Book Selection
Maximum Book Selection
Maximum Book Selection
In this problem, you are given a collection of books where each book has a positive integer value, and you have a limit L on the total allowable value. Your task is to select the maximum number of books such that the sum of their values does not exceed L. The optimal strategy is to pick the cheaper books first, ensuring that more books can be selected without breaching the limit. The formula for the book selection can be expressed in (O(n \log n)) time complexity due to the sort operation. For each test case, you will be given the value of N (number of books), the limit L, and a list of N book values.
inputFormat
The input is read from standard input (stdin). The first line contains an integer T, the number of test cases. Each test case consists of two lines. The first line of each test case contains two integers N and L, where N is the number of books and L is the total allowable value. The second line contains N space-separated integers representing the values of the books.
outputFormat
For each test case, output a single integer on a new line representing the maximum number of books that can be taken without exceeding the total value limit L. The output is printed to standard output (stdout).## sample
1
5 10
1 3 5 7 9
3