#C. Electrification

    Type: RemoteJudge 2000ms 256MiB

Electrification

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Description

At first, there was a legend related to the name of the problem, but now it's just a formal statement.

You are given nn points a1,a2,,ana_1, a_2, \dots, a_n on the OXOX axis. Now you are asked to find such an integer point xx on OXOX axis that fk(x)f_k(x) is minimal possible.

The function fk(x)f_k(x) can be described in the following way:

  • form a list of distances d1,d2,,dnd_1, d_2, \dots, d_n where di=aixd_i = |a_i - x| (distance between aia_i and xx);
  • sort list dd in non-descending order;
  • take dk+1d_{k + 1} as a result.

If there are multiple optimal answers you can print any of them.

The first line contains single integer TT (1T2105 1 \le T \le 2 \cdot 10^5) — number of queries. Next 2T2 \cdot T lines contain descriptions of queries. All queries are independent.

The first line of each query contains two integers nn, kk (1n21051 \le n \le 2 \cdot 10^5, 0k<n0 \le k < n) — the number of points and constant kk.

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (1a1<a2<<an1091 \le a_1 < a_2 < \dots < a_n \le 10^9) — points in ascending order.

It's guaranteed that n\sum{n} doesn't exceed 21052 \cdot 10^5.

Print TT integers — corresponding points xx which have minimal possible value of fk(x)f_k(x). If there are multiple answers you can print any of them.

Input

The first line contains single integer TT (1T2105 1 \le T \le 2 \cdot 10^5) — number of queries. Next 2T2 \cdot T lines contain descriptions of queries. All queries are independent.

The first line of each query contains two integers nn, kk (1n21051 \le n \le 2 \cdot 10^5, 0k<n0 \le k < n) — the number of points and constant kk.

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (1a1<a2<<an1091 \le a_1 < a_2 < \dots < a_n \le 10^9) — points in ascending order.

It's guaranteed that n\sum{n} doesn't exceed 21052 \cdot 10^5.

Output

Print TT integers — corresponding points xx which have minimal possible value of fk(x)f_k(x). If there are multiple answers you can print any of them.

Sample Input 1

3
3 2
1 2 5
2 1
1 1000000000
1 0
4

Sample Output 1

3
500000000
4

20240326集训

Not Attended
Status
Done
Rule
IOI
Problem
7
Start at
2024-3-26 19:00
End at
2024-3-26 21:00
Duration
2 hour(s)
Host
Partic.
14