Gift Shop and Coupon

 Chef wants to impress Chefina by giving her the maximum number of gifts possible.

Chef is in a gift shop having N items where the cost of the ith item is equal to Ai. Chef has K amount of money and a 50% off discount coupon that he can use for at most one of the items he buys.

If the cost of an item is equal to X, then, after applying the coupon on that item, Chef only has to pay X2 (rounded up to the nearest integer) amount for that item.

Help Chef find the maximum number of items he can buy with K amount of money and a 50% discount coupon given that he can use the coupon on at most one item.

Input Format

  • The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
  • The first line of each test case contains two space-separated integers N and K.
  • The next line contains N space-separated integers, where the ith integer Ai denotes the cost of the ith item.

Output Format

For each test case, print a single line containing one integer ― the maximum number of items Chef can buy.

Constraints

  • 1T103
  • 1N105
  • 1Ai109
  • 0K109
  • Sum of N over all test cases does not exceed 2105.

Sample Input 1 

3
1 4
5
3 15
4 4 5
3 10
6 7 4

Sample Output 1 

1
3
2

Explanation

Test case 1: After applying the discount, Chef can buy the only available item at 52=3.

Test case 2: Chef can buy all three items even without using the coupon.

Test case 3: After applying coupon on the third item, Chef can buy the second and the third item at 7+42= 7+2=9.

Previous
Next Post »