#P3826. [NOI2017] 蔬菜
[NOI2017] 蔬菜
Description
Xiao N is the administrator of a vegetable warehouse, responsible for designing a sales plan for the vegetables.
There are types of vegetables stored in the warehouse. Xiao N needs to design a reasonable sales plan by considering various factors based on the characteristics of different vegetables, in order to obtain the maximum profit.
When calculating the profit from selling vegetables, for each unit of the -th vegetable sold, a profit of is obtained.
In particular, due to policies that encourage diversified sales, the first time the -th vegetable is sold, an additional bonus profit of is also obtained.
At the beginning of operations, the inventory of the -th vegetable is units.
However, vegetables have a very limited freshness period. Once spoiled, they cannot be sold. Fortunately, Xiao N has already calculated the spoilage time of each unit of vegetable: for the -th vegetable, there exists a freshness parameter . At the end of each day, units of this vegetable will spoil, until all units have spoiled. (Note: The spoilage time of each unit is fixed and does not change due to sales.)
Formally: for every positive integer such that , there will be units of the -th vegetable spoiling at the end of day .
In particular, if , then units of the -th vegetable will spoil at the end of day .
Note that when , it means this vegetable never spoils.
Meanwhile, the total number of vegetables that can be sold per day is limited to at most units.
Now, Xiao N has questions and asks for your help. Each question is: given , if sales last for days, what is the maximum profit that can be obtained?
Input Format
The first line contains three positive integers , representing the number of vegetable types, the maximum total number of vegetable units that can be sold per day, and the number of questions asked by Xiao N, respectively.
The next lines each contain four non-negative integers describing the characteristics of one type of vegetable, in the order , with meanings as described above.
The next lines each contain one non-negative integer , with the meaning as described above.
Output Format
Output lines. The number on the -th line is the answer to the -th question.
2 3 2
3 3 3 3
2 5 8 3
1
3
16
27
Hint
Sample Explanation
There are two types of vegetables:
For the -st vegetable, the profit per unit sold is , and an additional bonus profit of is obtained when selling this vegetable for the first time. There are units in total, and all of them will spoil at the end of day .
For the -nd vegetable, the profit per unit sold is , and an additional bonus profit of is obtained when selling this vegetable for the first time. There are units in total, among which units spoil at the end of day , units spoil at the end of day , and units spoil at the end of day .
If sales last for day, you should sell units of the first vegetable and unit of the second vegetable.
In this case: the profit from selling the first vegetable is ; the profit from selling the second vegetable is ; the total profit is .
If sales last for days, on day you should sell units of the first vegetable, on day you should sell units of the second vegetable (choose the units that will spoil at the end of day ), and on day you should sell units of the second vegetable.
In this case: the profit from selling the first vegetable is ; the profit from selling the second vegetable is ; the total profit is .
Constraints
::cute-table{tuack} | Test point ID | | | | Feature | Feature | | :-----------: | :---------: | :-------: | :--------: | :---------: | :---------------: | | | | | | No | No | | | | ^ | ^ | ^ | ^ | | | | ^ | ^ | ^ | ^ | | | | ^ | | ^ | ^ | | | ^ | ^ | | ^ | ^ | | | ^ | ^ | | ^ | ^ | | | | | ^ | ^ | ^ | | | | | | ^ | ^ | | | | | | ^ | ^ | | | | | | ^ | ^ | | | | | | ^ | ^ | | | | | | Yes | ^ | | | ^ | ^ | ^ | No | Yes | | | ^ | ^ | ^ | ^ | No | | | ^ | ^ | ^ | ^ | ^ | | | | ^ | | Yes | Yes | | | ^ | ^ | ^ | ^ | No | | | ^ | ^ | ^ | No | Yes | | | ^ | ^ | ^ | ^ | No | | | ^ | ^ | ^ | ^ | ^ | | | | ^ | | Yes | Yes | | | ^ | ^ | ^ | ^ | No | | | ^ | ^ | ^ | No | Yes | | | ^ | ^ | ^ | ^ | No | | | ^ | ^ | ^ | ^ | ^ |
Feature : all are .
Feature : all are .
For all testdata, it is guaranteed that the in the queries are pairwise distinct.
For all testdata, it is guaranteed that , .
Translated by ChatGPT 5
京公网安备 11011102002149号