D. Removing Subarrays
time limit per test
5 с
memory limit per test
512 megabytes
input
standard input
output
standard output

Alex has an array $$$a_1,a_2,...,a_n$$$. A subarray $$$a_l, a_{l+1},...,a_r$$$ is good if both of the following are true:

  1. $$$r-l+1 \geq 2$$$
  2. $$$\max(a_l, a_{l+1},...,a_r)-\min(a_l, a_{l+1},...,a_r) \leq k$$$

In one operation, Alex can remove any good subarray $$$a_l, a_{l+1},...,a_r$$$ for a cost of $$$\lfloor \frac{r-l+1}{2} \rfloor$$$. He can perform the operation as many times as he likes (possibly zero times). Find the minimum size of the array that he can get as well as the minimum cost to obtain an array of minimum size.

Input

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

The first line of each testcase contains $$$2$$$ integers, $$$n$$$ and $$$k$$$ $$$(1 \leq n \leq 500, 0 \leq k \leq 10^9)$$$.

The second line contains $$$n$$$ integers, $$$a_1, a_2,..., a_n$$$ $$$(1 \leq a_i \leq 10^9)$$$.

It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$500$$$.

Output

For each test case output $$$2$$$ integers, the minimum size of the array that Alex can get followed by the minimum cost to obtain an array of minimum size.

Example
Input
5
6 0
1 1 5 5 1 1
6 4
1 1 5 5 1 1
6 1
4 3 3 1 1 6
10 2
3 5 3 6 4 2 2 3 3 8
1 0
1
Output
0 3
0 2
1 2
0 4
1 0
Note

In the first test case, the array is initially $$$[1, 1, 5, 5, 1, 1]$$$. Alex can remove subarray $$$[5, 5]$$$ for a cost of $$$1$$$ causing the array to become $$$[1, 1, 1, 1]$$$. He can then remove subarray $$$[1, 1, 1, 1]$$$ for a cost of $$$2$$$ causing the array to become empty.

In the second test case, the array is initially $$$[1, 1, 5, 5, 1, 1]$$$. Alex can remove subarray $$$[1, 1, 5]$$$ for a cost of $$$1$$$ causing the array to become $$$[5, 1, 1]$$$. He can then remove subarray $$$[5, 1, 1]$$$ for a cost of $$$1$$$ causing the array to become empty.

Problem Credits: Alex Liang and Larry Xing