#C7068. Maximum Marbles

    ID: 50898 Type: Default 1000ms 256MiB

Maximum Marbles

Maximum Marbles

Chef is given a set of marbles, each with an associated point value. He wants to pick as many marbles as possible without the total points exceeding a given limit (P). To achieve this, Chef picks the marbles with the smallest points first. Formally, given a sequence of point values (a_1, a_2, \dots, a_n), Chef needs to determine the largest integer (k) such that (\sum_{i=1}^{k} a_i \leq P). Your task is to find this maximum number of marbles for each test case.

inputFormat

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 (P), where (N) is the number of marbles and (P) is the maximum allowed points. The second line contains (N) space-separated integers representing the point values of each marble.

outputFormat

For each test case, output a single line containing one integer: the maximum number of marbles that Chef can pick without exceeding (P).## sample

2
3 10
4 7 2
5 15
1 3 5 9 4
2

4

</p>