CF-2272C•Codeforces

Yet Another Black Cell Problem

binary searchconstructive algorithmsdpgreedy

Inspired by this problem.

There is a strip divided into cells numbered from 00 to 10910^9 from left to right. Initially, all cells are white.

An array aa of length nn is given, containing the indices of nn cells. We want to paint all these nn cells black.

Given an integer xx, you may choose an integer yy such that 0≤y≤x0 \le y \le x, and then arbitrarily select yy cells that are not in aa. We also want to paint these selected yy cells black while keeping all non-selected cells white.

You may perform the following operation any number of times:

  • Choose two distinct cells ii and jj such that 1≤∣i−j∣≤k1 \le |i-j| \le k, and paint them black, regardless of whether they were originally black or white.

Find the minimum value of kk for which it is possible to paint all the required cells black while keeping other cells white.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤1041 \le t \le 10^4). The description of the test cases follows.

The first line of each test case contains two integers nn and xx (2≤n≤2⋅105,0≤x≤n2\leq n\leq 2\cdot 10^5,0\leq x\leq n).

The second line contains nn integers a1,a2,…,ana_1,a_2,\ldots,a_n (0≤ai≤1090\leq a_i\leq 10^{9}). It is guaranteed that ai<ai+1a_i \lt a_{i+1} for all 1≤i<n1 \leq i \lt n.

It is guaranteed that the sum of nn over all test cases does not exceed 2⋅1052\cdot 10^5.

Output

For each test case, print a single integer — the minimum value of kk for which it is possible to paint all the required cells black while keeping other cells white.

Note

In the first example, we cannot paint any cell other than 11 and 33 black because x=0x=0. So it's optimal to set k=2k=2 and choose i=1,j=3i=1,j=3 in the first operation.

In the second example, we can set k=1k=1, which is the minimal available value. We first choose i=1,j=2i=1,j=2 to paint and then choose i=2,j=3i=2,j=3 to paint. After that, cells 1,2,31,2,3 are painted black, only cell 22 is not in the given list, which satisfies the condition x=1x=1.

Sample 1
Input
4
2 0
1 3
2 1
1 3
3 1
2 5 7
10 2
0 6 8 10 13 14 16 19 25 31
Output
2
1
2
3

Discussions & Comments

Share your approach or ask questions about this problem (0)

You must be logged in to comment or start a discussion on this problem.

Log In

No comments yet. Be the first to comment!

Actions

Open on Codeforces

About Platform

CO
Codeforces
External Judge

Problem Discussions

0

Have questions or want to share your solution approach? Join the discussion.

View / write comments