#C2640. Maximum Boxes Stored

    ID: 45979 Type: Default 1000ms 256MiB

Maximum Boxes Stored

Maximum Boxes Stored

You are given a warehouse with a certain capacity C and a list of boxes with their respective weights. For each test case, determine the maximum number of boxes that can be stored in the warehouse without exceeding its capacity.

You are allowed to choose the boxes in any order. To maximize the number, the optimal strategy is to pick the lightest boxes first. Formally, given a capacity \( C \) and a sorted list of weights \( w_1 \le w_2 \le \dots \le w_N \), you must choose a prefix of the list such that \( \sum_{i=1}^k w_i \le C \) and \( \sum_{i=1}^{k+1} w_i > C \) if \( k < N \).

Your task is to implement a solution that reads the input from standard input and writes the result to standard output.

inputFormat

The first line contains an integer T representing the number of test cases. Each test case consists of two lines:

  • The first line contains two integers N and C, where N is the number of boxes and C is the capacity of the warehouse.
  • The second line contains N space-separated integers representing the weights of the boxes.

outputFormat

For each test case, output a single line containing the maximum number of boxes that can be stored in the warehouse.

## sample
2
5 10
2 3 5 4 6
3 8
7 3 2
3

2

</p>