#P9214. Task Distribution on Evaluation Nodes

    ID: 22369 Type: Default 1000ms 256MiB

Task Distribution on Evaluation Nodes

Task Distribution on Evaluation Nodes

There are (n) evaluation nodes with identical performance, labeled (1, 2, \ldots, n). At a certain moment, (m) evaluation tasks arrive simultaneously, labeled (1, 2, \ldots, m), and the required evaluation time for the tasks are (t_1, t_2, \ldots, t_m) respectively. Each evaluation task requires exactly one evaluation node to run. The tasks are assigned sequentially from task 1 to task (m) by the following rule: for the current task with evaluation time (t_i), assign it to the evaluation node which currently has the smallest cumulative evaluation time (i.e. the sum of the evaluation times of tasks already assigned to that node). If there are multiple such nodes, choose the one with the smallest label.

The cumulative evaluation time of an evaluation node that has been assigned tasks (a_1, a_2, \ldots, a_k) is defined as: [ \text{cumulative time} = t_{a_1} + t_{a_2} + \cdots + t_{a_k}. ]

Your task is to determine which evaluation tasks are assigned to each of the (n) evaluation nodes.

inputFormat

The first line contains two integers (n) and (m) (the number of evaluation nodes and the number of tasks, respectively). The second line contains (m) integers (t_1, t_2, \ldots, t_m) representing the evaluation time for each task.

outputFormat

Output (n) lines. The (i)-th line ((1 \leq i \leq n)) should contain the labels of the tasks assigned to evaluation node (i), in the order they were assigned. If an evaluation node receives no tasks, output an empty line.

sample

3 5
1 2 3 4 5
1 4

2 5 3

</p>