#K78117. Maximum Purchases

    ID: 35016 Type: Default 1000ms 256MiB

Maximum Purchases

Maximum Purchases

You are given a fixed amount of money M and a list of prices for different items. Your task is to determine the maximum number of items you can purchase without exceeding the money available. The strategy to achieve this is to sort the list of prices in ascending order and then select items from the beginning until adding the next item would exceed M. Mathematically, you want to find the largest integer k such that

\(\sum_{i=1}^{k} a_i \le M\)

where \(a_i\) are the item prices in sorted order.

inputFormat

The input is read from stdin and has the following format:

  • The first line contains an integer T, the number of test cases.
  • For each test case:
    • The first line contains two space-separated integers n and k, where n is the number of items and k is the available amount of money.
    • The second line contains n space-separated integers representing the prices of the items.

outputFormat

For each test case, output a single integer on a new line representing the maximum number of items that can be purchased without exceeding the amount.

## sample
3
7 50
1 12 5 111 200 1000 10
5 35
20 10 5 30 70
4 100
1 2 3 4
4

3 4

</p>