Eating Queries Codeforces Solution | Codeforces Problem Solution 2022
Timur has candies. The -th candy has a quantity of sugar equal to . So, by eating the -th candy, Timur consumes a quantity of sugar equal to .
Timur will ask you queries regarding his candies. For the -th query you have to answer what is the minimum number of candies he needs to eat in order to reach a quantity of sugar greater than or equal to or print -1 if it's not possible to obtain such a quantity. In other words, you should print the minimum possible such that after eating candies, Timur consumes a quantity of sugar of at least or say that no possible exists.
Note that he can't eat the same candy twice and queries are independent of each other (Timur can use the same candy in different queries).
The first line of input contains a single integer () — the number of test cases. The description of test cases follows.
The first line contains integers and () — the number of candies Timur has and the number of queries you have to print an answer for respectively.
Most Similar Words Codeforces Solution
The second line contains integers () — the quantity of sugar in each of the candies respectively.
Then lines follow.
Each of the next lines contains a single integer () – the quantity Timur wants to reach for the given query.
It is guaranteed that the sum of and the sum of over all test cases do not exceed .
For each test case output lines. For the -th line output the number of candies Timur needs to eat in order to reach a quantity of sugar greater than or equal to or print -1 if it's not possible to obtain such a quantity.
Join Now for Solution:-
No comments:
Post a Comment