#K3056. Maximum Challenges Completion

    ID: 24873 Type: Default 1000ms 256MiB

Maximum Challenges Completion

Maximum Challenges Completion

You are given a series of challenges, each with a required time to complete. For each test case, you are provided with the number of challenges N, the available total time M in minutes, and a list of N integers representing the time (in minutes) to complete each individual challenge.

Your task is to determine the maximum number of challenges that can be completed within the total time M. You are allowed to complete the challenges in any order, but naturally, it is optimal to complete the ones taking the least amount of time first.

The solution strategy is to sort the list of challenge times in non-decreasing order and then iterate through them, summing the times until you reach or exceed the limit M.

Note: All formulas appear in LaTeX format where applicable. For example, the main condition is:

\( total\_time + time \le M \)

inputFormat

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

T
N1 M1
challenge1[1] challenge1[2] ... challenge1[N1]
N2 M2
challenge2[1] challenge2[2] ... challenge2[N2]
...
NT MT
challengeT[1] challengeT[2] ... challengeT[NT]

Here, T is the number of test cases. For each test case, the first line contains two integers where N is the number of challenges and M is the total available time. The next line contains N integers representing the time each challenge requires.

outputFormat

For each test case, output a single integer on a new line, representing the maximum number of challenges that can be completed without exceeding the total time M. The output is written to stdout.

## sample
2
5 50
10 20 30 40 15
4 45
10 20 15 25
3

3

</p>