In the event of technical difficulties with Szkopuł, please contact us via email at [email protected].
If you would like to talk about tasks, solutions or technical problems, please visit our Discord servers. They are moderated by the community, but members of the support team are also active there.
A Sports Day is being held in a primary school in Gdynia. The most important part of the event is the Annual Football Cup.
Several children gathered at the football pitch, where teams were to be formed. As everyone wanted to belong to the best team, the players could not reach an agreement. Some of them threatened not to play, others started to cry and now nobody is sure if the tournament will take place at all.
Byteman, a sports teacher, is in charge of organizing the tournament.
He decided to split the children into teams himself, so that no player
would be unhappy with her team.
The -th of the
children on the pitch (numbered
through
)
said that she will be unhappy with her team if the team consists of less
than
players.
Apart from satisfying the children's requirements, Byteman would like to maximize the total number of teams. If there are still many possibilities, he requests the size of the largest team to be as small as possible. As it turned out to be quite a difficult task, Byteman asked you for help.
In the first line of the standard input there is one integer
(
).
Then,
lines follow.
The
-th of these lines contains a single integer
(
) that denotes the minimum team size that
satisfies the child number
.
Additionally, in test cases worth at least points,
will not exceed
.
In the first line of the standard output your program should write
a single integer equal to the maximum possible number of teams.
Then,
lines containing a description of the teams should follow.
The
-th of these lines should contain an integer
(
) denoting the size of the
-th team, and then
integers
(
for
), denoting the numbers of children belonging to the
team
.
If there are many possible answers, you can output any of the solutions
which minimize the size of the largest team (among all the solutions
consisting of exactly
teams).
For the input data:
5 2 1 2 2 3
the correct result is:
2 2 4 2 3 5 1 3
Task author: Adam Karczmarz.