Consider the sequence . If we use separators among those numbers, we get subsequences. Let be the sum of the elements of the -th subsequence. Let be the minimum , and let be the maximum . Given and , please choose where to place the separators so that is as small as possible.
Input consists of several cases, each one with and . You can assume and .
For every case, print lines. On the first line print the minimum . Afterwards, print a line for each of the subsequences, in order, with the numbers and their sum. Finally, print a line with 10 dashes. Follow exactly the format of the sample output. If there is more than one optimal solution, choose any one.
The expected solution is a dynamic programming. This problem could also be solved by precomputing the solutions. But, if you do that, your solution will be manually rejected.
Author: Josep Grané
Generation: 2026-01-25T11:04:18.924Z
© Jutge.org, 2006–2026.
https://jutge.org