Submit | All submissions | Best solutions | Back to list |
NITK01 - MIKE AND RACHAEL |
Mike wants to gift his girlfriend Rachael something. so he decides to buy some chocolates for her. Mike has a limited amount of money, but he wants to buy as many unique chocolates as he can. So, he is in a dilemma and is wondering how he can maximize the number of chocolates he can buy. He has N items in front of him, tagged with their prices and he has only P rupees.
Now, you being Mike’s best friend have the task to help him buy as many chocolates for his girlfriend as possible.
Input
The first line contains the number of test cases T.
The line for each test case will contain two inputs N and P, followed by a line containing N integers.
1 <= T <= 100
1 <= N <= 105
1 <= P <= 109
1 <= price of any chocolate <= 109
Output
Maximum number of chocolates Mike can buy for Rachael.
Example
Input: 1 7 50 1 12 5 111 200 1000 10 Output: 4
Explanation
He can buy only 4 chocolates at most. These chocolates have the following prices: 1, 12, 5, 10.
Added by: | Gaurav Jain |
Date: | 2013-09-24 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |