CF1826A Trust Nobody
题目描述
有由 $n$ 个人组成的群体,其中的一部分人被称为“说谎者”,总是说谎话,另一部分人总是说真话。对于 $1\leq i \leq n$ ,第 $i$ 个人说:“在我们中间至少有 $l_i$ 个人说谎话。”写一个程序判断人们所说的是矛盾的,还是可能存在的。如果是可能存在的,输出群体中说谎者的数量,如果有多种可能,输出其中任意一种即可。
输入格式
第一行一个整数 $t(1 \leq t \leq 1000)$ ,代表测试数据的组数。
对于每一组测试数据:
第一行一个整数 $n(1 \leq n \leq 100)$ ,代表群体中的人数。
第二行共 $n$ 个数,以空格隔开,对于 $1\leq i \leq n$,第 $i$ 个数代表 $l_i$ 。
数据保证 $\displaystyle\sum n \leq 10^4$。
输出格式
对于每一组测试数据,输出一个整数。如果人们所说的是矛盾的,输出 $-1$ ,否则,输出群体中说谎者的数量,如果有多种可能,输出其中任意一种即可。
说明/提示
In the first example, the only possible answer is that the second person is a liar, so the answer is $ 1 $ liar.
In the second example, it can be proven that we can't choose the liars so that all the requirements are satisfied.
In the third example, everybody tells the truth, so the answer is $ 0 $ liars.