Question: chef wants to make a purchase. For this, he needs Xgold coins, but he has none at the moment. Chef has N fixed deposits, the
chef wants to make a purchase. For this, he needs Xgold coins, but he has none at the moment.
Chef has N fixed deposits, the ithof which is worth Ai coins. He wants to open the minimum number of these deposits so that he has at least X coins.
You have to tell Chef the minimum number of fixed deposits he must open in order to have X coins, or say that this is impossible.
Input Format
The first line of 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 X, as described in the statement.
The second line of each test case contains Nspace-separated integers the ithith of which is Ai.
Output Format
For each test case, output one line containing the answer the minimum number of FDs Chef must open to have at least X coins. If it is not possible for him to open FDs such that he has at least X coins, output 11.
Constraints
1T,Ai,N1001T,Ai,N100
1X1041X104
Subtasks
Subtask #1 (100 points): Original constraints
Sample Input 1
4 4 6 4 3 5 1 3 15 1 5 3 2 5 10 3 4 7 1 2 3 4
Sample Output 1
2 -1 1 2
Explanation
Test case 11: Chef can open the first and second FDs to get 4+3=74+3=7 coins, which is more than the 66 coins he needs. There are other combinations of two FDs giving at least 66 coins for example, the first and third (for 4+5=94+5=9) and third and fourth (for 5+1=65+1=6), but there is no way to open only one FD and get 66 or more coins.
Test case 22: No matter which FDs Chef opens, he cannot have 1515 coins, so the answer is 11 even if he opens all of them, he will have only 1+5+3=91+5+3=9 coins.
Test case 33: Chef can open the first FD to obtain 1010 coins, which is larger than the 55 coins he needs.
Test case 44: Chef can open the third and fourth FDs to get 3+4=73+4=7 coins, which is enough because he needs 77 coins.
Author:
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
