#P11793. Orange Packaging
Orange Packaging
Orange Packaging
You are given n oranges arranged on a conveyor belt and numbered from \(1\) to \(n\). The \(i\)-th orange has a size \(A_i\). You need to partition these oranges into boxes such that the oranges in each box appear consecutively. Each box can contain at most \(m\) oranges. The cost to pack a box that contains \(s\) oranges, where the maximum size is \(a\) and the minimum size is \(b\), is given by the formula:
\(k + s \times (a - b)\)
Here, \(k\) is the fixed cost of the box. Your task is to determine the minimum total cost to pack all \(n\) oranges.
inputFormat
The first line contains three integers \(n\), \(m\), and \(k\).
The second line contains \(n\) integers \(A_1, A_2, \dots, A_n\), representing the sizes of the oranges.
outputFormat
Output a single integer representing the minimum total cost to pack all oranges.
sample
5 3 10
1 3 2 4 2
30
</p>