CF2160A.MEX Partition
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Let a partition of a multiset B be a collection of multisets s1,s2,…,sk such that each element appears the same number of times in B and across all of s1,s2,…,sk.
For example, some partitions of 1,2,3,3 include 1,3+2,3,1,2,3,3, and 2+1,3+3, but not 1,2+3.
A partition is called valid if the mex∗ of all multisets in the partition is the same. The score of a valid partition is the mex of any multiset in the partition.
You are given a multiset A of size n. Find the minimum score over all valid partitions of A.
∗The minimum excluded (MEX) of a collection of integers c1,c2,…,ck is defined as the smallest non-negative integer x which does not occur in the collection c.
设多重集 B 的一个划分为若干多重集 s1,s2,…,sk 构成的集合,使得每个元素在 B 中出现的次数与在所有 s1,s2,…,sk 中出现的总次数相等。
例如,多重集 {1,2,3,3} 的一些划分包括 {1,3}+{2,3}、{1,2,3,3} 和 {2}+{1,3}+{3},但 {1,2}+{3} 不是其划分。
若一个划分中所有多重集的 mex∗ 均相等,则称该划分是有效的。一个有效划分的得分定义为其中任意一个多重集的 mex 值。
给定一个大小为 n 的多重集 A,求 A 的所有有效划分中的最小得分。
∗ 一组整数 c1,c2,…,ck 的最小未出现值(MEX) 定义为不在该集合中出现的最小非负整数 x。
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤100). The description of the test cases follows.
The first line of each test case contains an integer n (1≤n≤100).
The second line contains n integers A1,A2,…,An denoting the elements of A (0≤Ai≤100).
It is not guaranteed that the elements are given in non-decreasing order.
每个测试包含多个测试用例。第一行包含测试用例的数量 t(1≤t≤100)。随后是各测试用例的描述。
每个测试用例的第一行包含一个整数 n(1≤n≤100)。
第二行包含 n 个整数 A1,A2,…,An,表示数组 A 的元素(0≤Ai≤100)。
不保证这些元素以非递减顺序给出。
输出格式
For each test case, output the minimum score over all valid partitions.
对于每个测试用例,输出所有有效划分中的最小得分。
输入输出样例
输入#1
2 3 0 0 0 2 1 2
输出#1
1 0
说明/提示
In the first test case, the minimum score of 1 can be obtained by the partition 0+0+0. The partition is valid because each multiset has a mex of 1, which is consequently the score of the partition.
In the second test case, we can use 1,2 as the only multiset in the partition, which has mex0.
在第一个测试用例中,通过划分 {0}+{0}+{0} 可以得到最小得分 1。该划分是合法的,因为每个多重集的 mex 均为 1,因此该划分的得分为 1。
在第二个测试用例中,我们可以将 {1,2} 作为划分中唯一的多重集,其 mex 为 0。
输入解题思路,AI测评打分。不知道怎么写?