luogu#P4699. [CEOI 2011] Teams

[CEOI 2011] Teams

Problem Description

There are nn children who want to take part in a competition, and they need to be divided into several teams. Each child has a requirement: the ii-th child requires that the team they are in must have at least aia_i people (including themselves).

Now you need to find a partition plan that, while satisfying all children’s requirements, maximizes the number of teams. Based on that, you should minimize the size of the largest team.

Input Format

The first line contains an integer nn, the number of children.

The next nn lines each contain one integer. The number on the ii-th line is aia_i.

Output Format

The first line contains an integer tt, the number of teams in your plan.

The next tt lines describe the teams, with several integers separated by spaces on each line. Each line first outputs an integer kik_i, the size of the ii-th team, followed by kik_i integers giving the indices of the children in that team (starting from 11).

If there are multiple solutions (while satisfying the requirements), output any one of them.

5
2
1
2
2
3
2
2 4 2
3 5 1 3

Hint

For 100%100\% of the testdata, 1n1 000 000;1ain1\le n\le 1\ 000\ 000;1\le a_i\le n, and the input is guaranteed to have a solution.

Translated by ChatGPT 5