cswork / OA打开练习工作台

SnowflakeOA #45

Selecting Stocks

估计中等可在线判题

考点(AI 标注)背包计数

Choose stocks with the available funds, buying at most one share per company, with a total purchase price not exceeding saving. The profit is the predicted future sale proceeds minus the purchase price, and buying no shares at all is allowed. Find the maximum profit, not the maximum total sales.

输入格式

The first line contains n saving, the second line contains currentValue, and the third line contains futureValue. This site adds 1≤n≤1000, 0≤saving≤10000, and 0≤each price≤10⁹, and a current or future price may be 0.

输出格式

Output the single integer required by the problem.

样例 1

输入:

5 250
175 133 109 210 97
200 125 128 228 133

输出:

55

样例 2

输入:

1 4
1
3

输出:

2

样例 3

输入:

2 0
0 1
5 0

输出:

5

样例说明

The answers to the three public examples are, in order: 55; 2; 5. The examples were checked by independent enumeration, state search, or direct simulation.