CF1175C.Electrification

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 ( $ 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.

输入输出样例

  • 输入#1

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

    输出#1

    3
    500000000
    4
    
首页