#P3983. 赛斯石(赛后强化版)
赛斯石(赛后强化版)
Description
We now need to bring to market Sais stones with a total weight of si. The seller wants to compute the maximum revenue obtainable by merging the si units in some way. However, there is a complication: the market is near the Zhencheng Grand Hall (the center of Zhencheng Ocean), and the seller needs to rent boats to deliver the Sais stones there (we do not count the cost for the seller himself to travel). There are ten types of boats available for rent, with carrying capacities from si to si, and each boat type has a different rental price, as shown in the table below.

Due to the strong Sais force near the Zhencheng Grand Hall, it is impossible to perform any operation on the Sais stones there. After the seller transports the Sais stones over, they can only be sold as pre-merged pieces. Assume the seller does not return and that all these Sais stones can be sold. Now the seller wants to calculate the total profit (let total profit = total revenue from Sais stones − total boat rental cost). Please design a program to find an optimal plan to obtain the maximum total profit.
Input Format
The input consists of two lines.
- The first line contains a single number (the total amount of Sais stones, unit: si).
- The second line contains ten numbers (the market prices, in yuan, for Sais stones of weights si to si, respectively).
Output Format
Output a single line containing one integer, the maximum total profit.
11
1 6 11 17 23 27 33 35 38 43
32
7
1 5 14 18 20 28 31 34 39 42
21
Hint
-
Sample explanation:
Merge units of si Sais stones into one si stone and one si stone, and rent two boats with capacities si and si. This is optimal, so the maximum total profit is yuan.
-
Notes:
For all input numbers, they are integers in the interval .
It is guaranteed that the maximum total profit is positive.
In the same line, there is one space between any two numbers.
The post-contest enhanced version was completed on -- 19 18 $.
Translated by ChatGPT 5
京公网安备 11011102002149号