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 n points a1,a2,…,an on the OX axis. Now you are asked to find such an integer point x on OX axis that fk(x) is minimal possible.
The function fk(x) can be described in the following way:
- form a list of distances d1,d2,…,dn where di=∣ai−x∣ (distance between ai and x );
- sort list d in non-descending order;
- take dk+1 as a result.
If there are multiple optimal answers you can print any of them.
输入格式
The first line contains single integer T ( $ 1 \le T \le 2 \cdot 10^5$ ) — number of queries. Next 2⋅T lines contain descriptions of queries. All queries are independent.
The first line of each query contains two integers n , k ( 1≤n≤2⋅105 , 0≤k<n ) — the number of points and constant k .
The second line contains n integers a1,a2,…,an ( 1≤a1<a2<⋯<an≤109 ) — points in ascending order.
It's guaranteed that ∑n doesn't exceed 2⋅105 .
输出格式
Print T integers — corresponding points x which have minimal possible value of fk(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