题目描述
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
There are n chocolates, and you are given an array of n numbers where the i-th number A_{i} is the flavour type of the i-th chocolate. Sebrina wants to eat as many different types of chocolates as possible, but she also has to save at least x number of chocolates for her little brother.
Find the maximum possible number of distinct flavour types Sebrina can have.
------ Input Format ------
The first line contains an integer T --- the number of test cases.
- The first line of each test case consists of two integers n, x - The number of chocolates Sabrina has and the number of chocolates she has to save for her brother, respectively.
- The second line contains $n integers A_{1},\ldots, A_{n}$, where the i-th chocolate has type A_{i}.
------ Output Format ------
For each test case, output a single integer denoting the maximum possible number of distinct chocolate flavours Sabrina can eat.
------ Constraints ------
$1≤T≤10$
$1 ≤x ≤ n ≤2 \cdot 10^{5}$
$1 ≤A_{i} ≤10^{9}$
- Sum of $n$ over all test cases do not exceed $2 \cdot 10^{5}$
----- Sample Input 1 ------
3
2 1
1 2
4 2
1 1 1 1
5 3
50 50 50 100 100
----- Sample Output 1 ------
1
1
2
----- explanation 1 ------
Test case $1$: In the first case, the maximum number of chocolates Sebrina can have is $1$ as she has to leave $1$ chocolate for her brother. Thus, the maximum number of distinct chocolates is also $1$.
Test case $2$: Sebrina has to leave $2$ chocolates for her brother. She can eat any $2$ chocolates. Since all the chocolates have the same flavor, it does not matter which chocolates she eats. The maximum number of distinct chocolates would be $1$.
Test case $3$: Sebrina needs to save $3$ chocolates for her brother. She can eat any $2$ chocolates. To maximize the number of distinct chocolates, she can eat chocolates $1$ and $5$ with flavors $50$ and $100$ respectively. Thus maximum number of distinct chocolates is $2$.
输入格式
见题面
输出格式
见题面