2139. Jewels

单点时限: 2.0 sec

内存限制: 256 MB

You are given N precious jewels of variable values each numbered 1-N and you need to put them in K safes. For security reasons each safe must carry consecutive block of jewels(eg:4,5,6 is allowed but 4,5,7 is not) and no safe must be empty.

Your task is to minimize the maximum cost of jewels that a single safe contains.

输入格式

The input consists of N cases (approx. 200). The first line of the input contains only positive integer N. Then follow the cases. Each case consists of exactly two lines. At the first line, there are two integers N and k, 1 <= k <= N <= 500. At the second line, there are integers p1, p2, … pN separated by spaces. All these values are positive and less than 10000.

输出格式

For each case, print exactly one line. The line must contain the input succession p1, p2, … pN divided into exactly k parts such that the maximum sum of a single part should be as small as possible. Use the slash character (‘-‘) to separate the parts. There must be exactly one space character between any two successive numbers and between the number and the slash. If there is more than one solution, print the one that minimizes the value of jewels in the first safe, then in the second safe etc. But each safe must must contain at least one jewel.

样例

Input
2
9 3
100 200 300 400 500 600 700 800 900
5 4
100 100 100 100 100
Output
100 200 300 400 500 - 600 700 - 800 900
100 - 100 - 100 - 100 100

1 人解决,3 人已尝试。

1 份提交通过,共有 25 份提交。

9.9 EMB 奖励。

创建: 15 年,11 月前.

修改: 6 年,8 月前.

最后提交: 15 年,9 月前.

来源: N/A

题目标签