P4699 [CEOI 2011] Teams

Description

There are $n$ children who want to take part in a competition, and they need to be divided into several teams. Each child has a requirement: the $i$-th child requires that the team they are in must have at least $a_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 $n$, the number of children. The next $n$ lines each contain one integer. The number on the $i$-th line is $a_i$.

Output Format

The first line contains an integer $t$, the number of teams in your plan. The next $t$ lines describe the teams, with several integers separated by spaces on each line. Each line first outputs an integer $k_i$, the size of the $i$-th team, followed by $k_i$ integers giving the indices of the children in that team (starting from $1$). If there are multiple solutions (while satisfying the requirements), output any one of them.

Explanation/Hint

For $100\%$ of the testdata, $1\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