#abc364d. D - K-th Nearest
D - K-th Nearest
Score : points
问题陈述
在数轴上有 个点 ,其中点 的坐标为 ,点 的坐标为 。
对于每个 ,回答以下问题:
- 设 是点 中距离点 第 近的点。找出点 和点 之间的距离。更正式地,设 为点 和点 之间的距离。将 按升序排列得到序列 。找出 。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
There are points on a number line, where point has a coordinate and point has a coordinate .
For each , answer the following question:
- Let be the point among that is the -th closest to point . Find the distance between points and . More formally, let be the distance between points and . Sort in ascending order to get the sequence . Find .
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print lines. The -th line should contain the answer to the question for as an integer.
Sample Input 1
4 3
-3 -1 5 6
-2 3
2 1
10 4
Sample Output 1
7
3
13
Let us explain the first query.
The distances from points to point are , respectively, so the 3rd closest to point is point . Therefore, print the distance between point and point , which is .
Sample Input 2
2 2
0 0
0 1
0 2
Sample Output 2
0
0
There may be multiple points with the same coordinates.
Sample Input 3
10 5
-84 -60 -41 -100 8 -8 -52 -62 -61 -76
-52 5
14 4
-2 6
46 2
26 7
Sample Output 3
11
66
59
54
88