P27829 [洛谷] [Language Month Competition 202304] Luogu Judging Machine Simulator
普及-
题目描述

Problem Background

Pretend you are the Luogu judging machine. On this day, Luogu simultaneously held PION self-test, SCP self-test, ION self-test, and other competitions. Thousands of evaluations have fallen onto you!

Problem Description

You are given \( n \) evaluation nodes of the same performance, numbered as \( 1, 2, \cdots, n \). Each evaluation node can only process one task at a time.

At a certain moment, \( m \) evaluation tasks simultaneously arrive. These tasks are numbered as \( 1, 2, \cdots, m \). The required evaluation times for these tasks are \( t_1, t_2, \cdots, t_m \). Each task requires and only requires one evaluation node to run. Therefore, you will allocate these tasks to the evaluation nodes sequentially in the order of \( 1 \sim m \) as follows:

For a task with duration \( t_i \), you need to find the evaluation node with the minimum cumulative evaluation time to place the task. If multiple nodes have the same minimum cumulative evaluation time, choose the node with the smallest number.

Cumulative evaluation time definition: Suppose for a certain evaluation node, it has been assigned \( a_1, a_2, \cdots, a_k \) tasks. Then the cumulative evaluation time of this node is \( t_{a_1} + t_{a_2} + \cdots + t_{a_k} \). Obviously, if an evaluation node has not been assigned any of these \( m \) tasks, its cumulative evaluation time is \( 0 \).

Now, you need to count which evaluation tasks each of your \( n \) evaluation nodes has accepted.

Input Format

The input consists of two lines.

The first line contains two integers \( n, m \), representing the number of evaluation nodes and the number of evaluation tasks, respectively.
The second line contains \( m \) integers \( t_1, t_2, \cdots, t_m \), representing the required times for these \( m \) evaluation tasks in order.

Output Format

The output consists of \( n \) lines, each containing several integers separated by a space.

For the \( i \)-th line, output the task numbers accepted by the \( i \)-th evaluation node in ascending order. If the \( i \)-th evaluation node has not been assigned any tasks, output a single line with a \( 0 \).

Sample Input and Output

Sample Input #1

5 10
13 50 90 38 60 64 60 77 6 24

Sample Output #1

1 6
2 8
3
4 7
5 9 10

Sample Input #2

12 7
85 99 82 90 14 11 15

Sample Output #2

1
2
3
4
5
6
7
0
0
0
0
0

Notes

Data Size and Constraints

For \( 100\% \) of the data, it is guaranteed that \( 1 \leq n, m \leq 5 \times 10^3 \) and \( 0 \leq t_i \leq 10^9 \).

Test Case Number \( n \leq \) \( m \leq \) Special Properties
\( 1 \sim 2 \) \( 10 \) \( 10 \) None
\( 3 \sim 4 \) \( 5 \times 10^3 \) \( 5 \times 10^3 \) \( t_i = 0 \)
\( 5 \sim 6 \) \( 5 \times 10^3 \) \( 5 \times 10^3 \) \( t_i = 1 \)
\( 7 \sim 10 \) \( 5 \times 10^3 \) \( 5 \times 10^3 \) None
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
5 10 13 50 90 38 60 64 60 77 6 24
样例输出
1 6 2 8 3 4 7 5 9 10