#P12733. 磨合
磨合
Description
Yuta and Saki encountered problems, where the difficulty of the problems are .
They can solve the problems in any order. For the -th problem they choose to solve, reducing the difficulty by will cost them seconds. Once the difficulty is reduced to , the problem is considered solved, and they can move on to the next problem.
If they're solving the -th problem (that is, the difficulty isn't reduced to yet) but the ramaining time is less than seconds, they cannot continue solving the remaining problems, and the -th problem is also considered unsolved.
They want to know, if they have a total time of seconds, what is the maximum number of problems they can solve. Since they may face many different scenarios, they will repeatedly change the possible values of and ask this question.
Input Format
The first line contains two integers, and , representing the number of problems and the number of queries, respectively.
The second line is consisted of integers representing .
The following lines, each line contains an integer representing the total time for the query.
Output Format
For each query, output a single integer on a line indicating the maximum number of problems that can be solved.
3 2
1 7 3
10
16
2
3
10 3
923 243 389 974 100 485 296 377 61 552
2403
5819
0
5
6
0
Hint
Sample 1 Explanation
If , they can solve the problem with a difficulty of first, then solve the problem with a difficulty of , it will consume seconds. It can be proven that they cannot solve three problems.
If , then solving the problems with difficulty values of , , and in sequence would consume seconds.
Constraints
This problem enables subtask scoring and subtask dependence, with the constraints and scores for each subtask as follows.
| Subtask No. | Score | Depends on Subtask | ||||
|---|---|---|---|---|---|---|
For all of the testdata, , , .
京公网安备 11011102002149号