This page is still under construction.

Parts of this page are still being built. What you see may change.

Social Distancing

Interview

Time limit1sMemory limit512 MB

Summary
Choose s of n outlet positions to maximize the minimum distance between any two chosen seats.
Level

Medium5 of 10

Topics
Binary search, Greedy, Sorting, Array
Solved
No attempts yet

Problem

Albert has agreed to help run a Hackathon hosted by University L. Under the social distancing policy, he wants to assign seats so that all participants are as far apart as possible. To do this, he places monitors, desks, and chairs at specific positions along a very long hallway, and each seat can hold at most one team. A total of ss teams take part in the event, and nn power outlets are installed along the hallway. A seat can only be placed where an outlet is installed. For convenience, let the positions of the outlets be x[1],x[2],…,x[n]x[1], x[2], \ldots, x[n], where each x[i]x[i] is the distance from the hallway entrance. That is, the ii-th outlet is x[i]x[i] away from the hallway entrance.

Albert wants to choose ss of the nn outlet positions for seats so that the distance between the two closest seats, call it DD, is as large as possible.

For example, let n=3n = 3, s=3s = 3, and x=[10,100,200]x = [10, 100, 200]. Here n=sn = s, so a seat must be placed at every outlet position. The distance between the two closest seats is 100−10=90100 - 10 = 90. As another example, let n=6n = 6, s=4s = 4, and x=[11,19,24,26,29,30]x = [11, 19, 24, 26, 29, 30]. Placing seats at x[1]=11x[1] = 11, x[2]=19x[2] = 19, x[3]=24x[3] = 24, and x[4]=29x[4] = 29 makes the distance between the two closest seats 5. Choosing x[1]=11x[1] = 11, x[2]=19x[2] = 19, x[3]=24x[3] = 24, and x[4]=30x[4] = 30 also works. There is no way to place 4 seats so that the distance between the two closest seats is at least 6.

Given nn, ss, and x[1],…,x[n]x[1], \ldots, x[n], write a program that prints the largest possible value of DD.

Input

The first line gives the number of test cases TT. Each test case spans two lines.

The first line gives nn and ss separated by a space. The next line gives nn integers separated by spaces, the positions of the installed outlets.

Output

For each test case, print the largest achievable value of DD.

Constraints

  • 1≤T≤101 \le T \le 10
  • 2≤s≤n≤200,0002 \le s \le n \le 200,000
  • 1≤x[i]≤1,000,000,0001 \le x[i] \le 1,000,000,000
  • The values x[i]x[i] are distinct.

Examples1

  1. Example 1

    Input
    3
    3 3
    10 100 200
    7 3
    28 11 17 19 21 22 23
    6 4
    11 19 24 26 29 30
    
    Expected output
    90
    8
    5