#B3746. Task Scheduling with Evaluation Nodes
Task Scheduling with Evaluation Nodes
Task Scheduling with Evaluation Nodes
You are given n evaluation nodes, numbered from \(1\) to \(n\), each having identical performance. Each node can process only one evaluation task at a time. At a certain moment, m evaluation tasks arrive simultaneously, numbered from \(1\) to \(m\). The \(i\)-th task requires \(t_i\) units of time to complete.
The tasks are assigned in the order from \(1\) to \(m\) in the following manner:
For task \(i\) with processing time \(t_i\), assign it to the node with the minimum cumulative evaluation time. If there are multiple such nodes, choose the one with the smallest index.
\(\textbf{Definition:}\) The cumulative evaluation time for a node is defined as the sum of the evaluation times of the tasks already assigned to it. If a node has not been assigned any tasks, its cumulative evaluation time is \(0\).
Your task is to determine the list of tasks each of the \(n\) nodes receives.
inputFormat
The first line contains two integers \(n\) and \(m\) (the number of nodes and tasks, respectively).
The second line contains \(m\) integers \(t_1, t_2, \cdots, t_m\), where \(t_i\) is the evaluation time required for task \(i\).
outputFormat
Output \(n\) lines. The \(i\)-th line should list, in order of assignment, the IDs of the tasks assigned to node \(i\). If a node is not assigned any task, output an empty line.
sample
3 5
5 2 3 1 4
1
2 4 5
3
</p>