CF1342D Multiple Testcases

题目描述

给予$n$个整数$m_{1,2,...,n}$,现在要将它们放进若干容器,要求: - 在每个容器$p_j$中,对于每个数$i$($1 \le i \le k$),大于等于$i$的数不能超过$c_i$个。 求最小所需容器数以及安排方式,保证: - $1 \le n \le 2 \cdot 10^5$ - $1 \le k \le 2 \cdot 10^5$ - $1 \le m_i \le k$ - $n \ge c_1 \ge c_2 \ge ...\ge c_k \ge 1$

输入格式

- 第一行两个整数$n,k$。 - 第二行$n$个整数$m_{1,2,...,n}$。 - 第三行$k$个整数$c_{1,2,...,k}$。

输出格式

- 第一行输出最小容器数$ans$($1 \le ans \le n$)。 - 接下来输出$ans$行,第$i$行先输出一个整数$t$($1 \le t \le n$),接下来输出$t$个整数,表示第$i-1$个容器中的元素。 - $\sum t = n$。 - $m$中的每个数恰好在某个容器中出现一次。 - 输出任意一组最优解即可。 因为$c_k \ge 1$,所以一定存在一种合法分配方式。

说明/提示

In the first example there is no way to distribute the tests into less than $ 3 $ testcases. The given answer satisfies the conditions: each of the testcases includes no more than $ 4 $ arrays of size greater than or equal to $ 1 $ and no more than $ 1 $ array of sizes greater than or equal to $ 2 $ and $ 3 $ . Note that there are multiple valid answers for this test. For example, testcases with sizes $ [[2], [1, 2], [3]] $ would also be correct. However, testcases with sizes $ [[1, 2], [2, 3]] $ would be incorrect because there are $ 2 $ arrays of size greater than or equal to $ 2 $ in the second testcase. Note the difference between the third and the fourth examples. You can include up to $ 5 $ arrays of size greater than or equal to $ 1 $ in the third example, so you can put all arrays into a single testcase. And you can have only up to $ 1 $ array in the fourth example. Thus, every array should be included in a separate testcase.