Spenser has a big announcement. Are you ready?
Spenser's big announcement is
For each word, we know how many nanometers of width it takes up on the banner.
For readability purposes, two words that are adjacent on the same line line must be separated by exactly
Determine the optimal way to break up the message over the
Constraints
Subtask 1 [1 point]
Subtask 2 [1 point]
No additional constraints.
Input Specification
The first line contains three integers,
The next line contains
Sample Input 1
4 2 1
1 2 3 8
Sample Output 2
8
Sample Explanation 1
In this example, it is optimal to assign the first three words to the first line and the last word to the second line. The first three words will take up a total of 8 nanometers - 6 due to the width and 2 for the necessary gaps, and the last line will take up exactly 8 nanometers.
How Ampliteers will read the banner is an exercise left to Spenser.
Sample Input 2
12 1 100000000
100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000
Sample Output 2
2300000000
Sample Explanation 2
Since there is only one line, there is only one way to format the banner.
Comments