Codeforces Round 1066 (Div. 1 + Div. 2)
A
Dungeon Equilibrium
Codeforces
800
原题
←B →
翻译中…
翻译中…

An array is called balanced if every integer $x$ that occurs at least once, occurs exactly $x$ times in the array. For example, $[1, 4, 2, 4, 4, 4, 2]$ is balanced, but $[2]$ and $[2, 2, 2]$ are not.

翻译中…

You are given an array $a$ of $n$ elements, $[a_1, a_2, \ldots, a_n]$. The array may not be balanced currently, and you can delete some elements to make it balanced. What is the minimum number of elements you need to delete to make the array balanced?

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 500$). The description of the test cases follows.

翻译中…

The first line of each test case contains an integer $n$ ($1 \leq n \leq 100$) — the size of the array $a$.

翻译中…

The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ($0 \leq a_i \leq n$) — the elements of the array $a$.

翻译中…

Note that there are no constraints on the sum of $n$ over all test cases.

翻译中…

Output

翻译中…

For each test case, output a single line containing an integer: the minimum number of elements you should remove from the array to make it balanced.

翻译中…

Note

翻译中…

In the first test case, the given array is already balanced.

翻译中…

In the second test case, we can delete one occurrence of $1$ and one occurrence of $3$ to get the array $[1, 2, 2]$ which is balanced.

翻译中…

样例

Input #1
4
3
1 2 2
5
1 1 2 2 3
10
1 2 3 2 4 4 4 4 5 2
1
0
Output #1
0
2
3
1
InputCopy OutputCopy
题目信息
题号
2157A
时间限制
1 s
内存限制
256 MB
标签
贪心
模拟
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。