#P2517. [HAOI2010] 订货

[HAOI2010] 订货

Description

A company estimates that in month ii the market demand for a certain product is UiU_i. It is known that the unit purchase price in month ii is did_i. For each unit of product that remains unsold at the end of a month and is carried over to the next month, a storage fee of mm must be paid. Assume the initial inventory at the beginning of month 11 is 00, and the inventory at the end of month nn is also 00. How should the ordering plan for these nn months be arranged to minimize the total cost?

Orders are placed at the beginning of each month. After ordering, products arrive immediately, enter the warehouse, and supply the market. If a unit is sold within the same month, no storage fee is charged for it. Assume the warehouse capacity is SS.

Input Format

Line 11: $n, m, S \ (0\le n\le50, 0\le m\le10, 0\le S\le10000)$.

Line 22: U1,U2,,Un (0Ui10000)U_1 , U_2 , \cdots , U_n \ (0\le U_i\le10000).

Line 33: d1,d2,,dn (0di100)d_1, d_2, \cdots ,d_n \ (0\le d_i\le100).

Output Format

Only 11 line, an integer representing the minimum cost.

3 1 1000
2 4 8
1 2 4 
34

Hint

Translated by ChatGPT 5