Chef and Fixed Deposits Problem Code: MINFD
Chef wants to make a purchase. For this, he needs gold coins, but he has none at the moment.
Chef has fixed deposits, the of which is worth coins. He wants to open the minimum number of these deposits so that he has at least coins.
You have to tell Chef the minimum number of fixed deposits he must open in order to have coins, or say that this is impossible.
Input Format
- The first line of input contains a single integer , denoting the number of test cases. The description of test cases follows.
- The first line of each test case contains two space-separated integers — and , as described in the statement.
- The second line of each test case contains space-separated integers — the of which is .
Output Format
For each test case, output one line containing the answer — the minimum number of FDs Chef must open to have at least coins. If it is not possible for him to open FDs such that he has at least coins, output .
Constraints
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 : Chef can open the first and second FDs to get coins.
Test case : No matter which FDs Chef opens, he cannot have coins, so the answer is .
Author: 2★aryanag_adm
Date Added: 13-01-2022
Time Limit: 1 secs
Source Limit: 50000 Bytes
Languages: CPP14, C, JAVA, PYTH 3.6, CPP17, PYTH, PYP3, CS2, ADA, PYPY, TEXT, PAS fpc, NODEJS, RUBY, PHP, GO, HASK, TCL, PERL, SCALA, LUA, kotlin, BASH, JS, LISP sbcl, rust, PAS gpc, BF, CLOJ, R, D, CAML, FORT, ASM, swift, FS, WSPC, LISP clisp, SQL, SCM guile, PERL6, ERL, CLPS, ICK, NICE, PRLG, ICON, COB, SCM chicken, PIKE, SCM qobi, ST, SQLQ, NEM
Comments
Post a Comment