#K9866. Maximum Dishes

    ID: 39125 Type: Default 1000ms 256MiB

Maximum Dishes

Maximum Dishes

Chef is planning a feast and he wants to try as many different dishes as possible. He has a limited budget of C coins and there are N dishes available with varying prices. Chef can buy a dish only once. In order to maximize the number of dishes he can afford, he should always buy the cheapest dishes first.

The problem can be mathematically formulated as follows: find the maximum integer k such that $$\sum_{i=1}^{k} price_i \le C,$$ where the pricei's represent the sorted prices of the dishes in non-decreasing order.

Your task is to help Chef determine the maximum number of different dishes he can purchase.

inputFormat

The first line of input contains a single integer T representing the number of test cases. Each test case is described as follows:

  • The first line contains two integers N and C representing the number of dishes and the number of coins Chef has.
  • The second line contains N space-separated integers representing the prices of the dishes.

It is guaranteed that all input values are valid.

outputFormat

For each test case, print a single integer in a new line representing the maximum number of different dishes Chef can purchase with his budget.

## sample
2
5 15
1 12 5 7 3
4 10
9 8 5 2
3

2

</p>