CF2057B.Gorilla and the Exam

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

Gorilla and the Exam

Due to a shortage of teachers in the senior class of the "T-generation", it was decided to have a huge male gorilla conduct exams for the students. However, it is not that simple; to prove his competence, he needs to solve the following problem.

For an array bb, we define the function f(b)f(b) as the smallest number of the following operations required to make the array bb empty:

  • take two integers ll and rr, such that lrl \le r, and let xx be the min(bl,bl+1,,br)\min(b_l, b_{l+1}, \ldots, b_r); then
  • remove all such bib_i that lirl \le i \le r and bi=xb_i = x from the array, the deleted elements are removed, the indices are renumerated.

You are given an array aa of length nn and an integer kk. No more than kk times, you can choose any index ii (1in1 \le i \le n) and any integer pp, and replace aia_i with pp.

Help the gorilla to determine the smallest value of f(a)f(a) that can be achieved after such replacements.

Input

Each test contains multiple test cases. The first line contains a single integer tt (1t1041 \le t \le 10^4) — the number of test cases. The description of the test cases follows.

The first line of each set of input data contains two integers nn and kk (1n1051 \le n \le 10^5, 0kn0 \le k \le n) — the length of the array aa and the maximum number of changes, respectively.

The second line of each set of input data contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (1ai1091 \le a_i \le 10^9) — the array aa itself.

It is guaranteed that the sum of the values of nn across all sets of input data does not exceed 10510^5.

Output

For each set of input data, output a single integer on a separate line — the smallest possible value of f(a)f(a).

Note

In the first set of input data, f([48843])=1f([48\,843]) = 1, since the array consists of a single number, and thus it can be removed in one operation.

In the second set of input data, you can change the second number to 22, resulting in the array [2,2,2][2, 2, 2], where f([2,2,2])=1f([2, 2, 2]) = 1, since you can take the entire array as a subarray, the minimum on it is 22, so we will remove all the 22s from the array, and the array will become empty.

Samples

6
1 0
48843
3 1
2 3 2
5 3
1 2 3 4 5
7 0
4 7 1 3 2 4 1
11 4
3 2 1 4 4 3 4 2 1 3 3
5 5
1 2 3 4 5
1
1
2
5
2
1

在线编程 IDE

建议全屏模式获得最佳体验