#P7997. [WFOI - 01] 刷题 (problem)
[WFOI - 01] 刷题 (problem)
Background
Problem Description
Your initial ability is .
There are problem sets. In the -th set, all problems have the same difficulty , and the number of problems can be considered infinite. Now you need to solve problems. Each time, you choose one problem from all available problems.
Suppose the difficulty of the problem you are currently solving is . Then:
- If your ability is greater than or equal to , you will spend your ability to defeat this problem (your ability decreases by ).
- Otherwise, you will study this problem carefully. After you figure it out, your ability increases by (this does not cause your ability to decrease).
Now you want to know the maximum possible ability after solving problems. Since your friends also want to solve problems, there are multiple queries. The queries are independent, meaning that in each query your initial ability is .
Input Format
The first line contains integers .
The second line contains integers, representing the array .
The next lines each contain one integer, representing a query.
Output Format
For each query, output the corresponding result.
5 3
1 2 3 4 6
1
2
3
6
10
11
1 2
1
1
2
1
0
Hint
-
Sample explanation:
When , choose in order.
When , choose in order.
When , choose in order.
-
Sample explanation:
When , choose in order.
When , choose in order.
This problem uses bundled Subtask testdata.
| Subtask ID | |||
|---|---|---|---|
| Subtask #0 () | |||
| Subtask #1 () | |||
| Subtask #2 () | |||
| Subtask #3 () | |||
| Subtask #4 () | |||
| Subtask #5 () | |||
For of the data, , , , and 。
Translated by ChatGPT 5