#C6074. Maximum Solved Problems
Maximum Solved Problems
Maximum Solved Problems
In this problem, you are given several test cases. For each test case, you are provided with a number of problems and a total available time. Each problem requires a certain amount of time to solve. Your task is to determine the maximum number of problems that can be solved if one picks problems in the order from the shortest to the longest, such that the sum of the times does not exceed the available time.
More formally, for each test case you are provided with two integers (N) and (M), where (N) is the number of problems and (M) is the total available time. Then, you are given (N) integers (t_1, t_2, \dots, t_N) representing the time required to solve each problem. You should select a subset of problems (by reordering them in non-decreasing order of required time) such that [ \sum_{i=1}^k t_i \le M ] and (k) is maximized.
Print the maximum count (k) for each test case on a new line.
inputFormat
The input is read from the standard input (stdin). The first line contains an integer (T), the number of test cases. For each test case, the first line contains two integers (N) and (M), where (N) is the number of problems and (M) is the total time available. The second line of each test case contains (N) space-separated integers representing the time required to solve each problem.
outputFormat
For each test case, output a single integer on a new line—the maximum number of problems that can be solved within the given total time.## sample
2
5 300
100 200 150 60 50
4 120
30 50 70 40
3
3
</p>