409351: GYM103488 E Equality
Description
Yzk has an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, a_3\dots a_n$$$. In one operation, he can select a continuous sub-array of exactly length $$$k$$$, then change all elements in the sub-array to the minimum element in this sub-array.
Please help him found the minimum number of operations to make all elements in the array $$$a$$$ equal.
InputThe first line contains one integer $$$T(1\le T\le 10^5)$$$ — the number of test cases.
The first line of each test case contains two integers $$$n, k(1\le k\le n\le 10^5)$$$ — the length of array $$$a$$$, and the length of sub-array Yzk should select.
The second line contains $$$n$$$ integers $$$a_1, a_2, a_3\dots a_n(1\le a_i \le 10^6)$$$. — the elements of array $$$a$$$.
It's guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$10^5$$$($$$\sum n\le 10^5$$$).
OutputFor each test case, output an integer in one line — the minimum number of operations to make all elements in the array $$$a$$$ equal. If it's impossible to do it, output -1.
ExampleInput4 5 3 3 4 1000000 5 3 5 3 1 2 1 3 1 2 1 1 1 2 1 1 2Output
2 1 0 -1Note
In the first test case, we can do $$$2$$$ operations as follows:
In the operation $$$1$$$, select sub-array $$$[a_1, a_2, a_3]$$$, the minimum element in $$$[a_1,a_2,a_3]$$$ is $$$a_1=3$$$, then array $$$a$$$ changes to $$$[3,3,3,5,3]$$$.
In the operation $$$2$$$, select sub-array $$$[a_3, a_4, a_5]$$$, the minimum element in $$$[a_3,a_4,a_5]$$$ is $$$a_3=a_5=3$$$, then array $$$a$$$ changes to $$$[3,3,3,3,3]$$$.