#P7997. [WFOI - 01] 刷题 (problem)

    ID: 9083 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>洛谷原创O2优化最短路其它技巧洛谷月赛

[WFOI - 01] 刷题 (problem)

Background

Simplified statement: Link\texttt{Link}.

Problem Description

Your initial ability is 00.

There are nn problem sets. In the ii-th set, all problems have the same difficulty aia_i, and the number of problems can be considered infinite. Now you need to solve mm problems. Each time, you choose one problem from all available problems.

Suppose the difficulty of the problem you are currently solving is xx. Then:

  • If your ability is greater than or equal to xx, you will spend your ability to defeat this problem (your ability decreases by xx).
  • Otherwise, you will study this problem carefully. After you figure it out, your ability increases by xx (this does not cause your ability to decrease).

Now you want to know the maximum possible ability after solving mm 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 00.

Input Format

The first line contains 22 integers n,Tn, T.

The second line contains nn integers, representing the array aa.

The next TT 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 11 explanation:

    When m=1m=1, choose 66 in order.

    When m=2m=2, choose 4,64,6 in order.

    When m=3m=3, choose 1,4,61,4,6 in order.

  • Sample 22 explanation:

    When m=1m=1, choose 11 in order.

    When m=2m=2, choose 1,11,1 in order.

This problem uses bundled Subtask testdata.

Subtask ID nn\le mm\le TT\le
Subtask #0 (5pts5\texttt{pts}) 55 100100
Subtask #1 (10pts10\texttt{pts}) 10510^5
Subtask #2 (10pts10\texttt{pts}) 200200 200200 100100
Subtask #3 (15pts15\texttt{pts}) 10510^5
Subtask #4 (10pts10\texttt{pts}) 101810^{18}
Subtask #5 (50pts50\texttt{pts}) 20002000

For 100%100\% of the data, 1T1051 \le T \le 10^5, 1n20001 \le n\le 2000, 1m10181 \le m \le 10^{18}, and i,0ai2000\forall i,0 \le a_i \le 2000

Translated by ChatGPT 5