#P1905. 堆放货物

堆放货物

Description

There are three types of goods in Genoa: pottery, furniture, and marble, with a total of nn items. Their weights are 11, 22, and 33 units, respectively. Now, there are pp ships from Capua waiting for goods from the warehouse. You should divide the goods in the warehouse into pp stacks according to the following rules:

  • Within the same stack, weights from bottom to top must be non-increasing (obviously, you cannot place marble on top of pottery or furniture).
  • The absolute difference between the total weights of any two stacks must not exceed 33 units; otherwise, conflicts may arise between ships due to overly uneven distribution.

Please complete this task and provide one feasible arrangement.

Input Format

The first line contains an integer, the number of goods nn.
The second line contains an integer, the number of stacks pp.
The third line contains nn integers; the ii-th integer is the weight aia_i of the ii-th item.

Output Format

This problem uses a Special Judge.

Output pp lines. Each line contains some integers describing one stack of goods, listing the weight of each item in that stack from bottom to top.

6
3
3 2 2 1 1 1

3 1
2 1
2 1

Hint

Constraints and Notes

For all test points, it is guaranteed that 2n1032 \leq n \leq 10^3, 1pn21 \leq p \leq \lfloor \frac{n}{2} \rfloor, and 1ai31 \leq a_i \leq 3.

Notes

Thanks to @cn: 苏卿念 for providing the spj.

SPJ description:

score:ouo:你的输出里面有不是'1','2','3',' ','\n','\r'的东西,具体以ASCII的第X号字符
score:pvp:你在第x组的时候装下了超过规定数量的'3'|'2'|'1'。
score:TAT:蛇皮judge没能读入到想要读入的东东(类似于你直接提交了一个puts(" / 特别特别多的空格/"))
score:qaq:你把重量为w1的货物放到了w2上面(w1>w2)在第i组的第j个货物
score:ovo:你没有装足够的x
score:qwq:你第i组和第j组的差的绝对值>3了,(要打架了),第i组的重量和为x,第j组的重量和为y。
score:pwp:答案正确,恭喜你嘤嘤嘤

Translated by ChatGPT 5