~/algor $ cat problems/qidiruv-k-chi-ayirma
k-th pair difference
Hard
2000 ms
128 MB
81%
An array $a$ of $n$ integers is given. For each pair $i \lt j$ the difference $|a_{i} - a_{j}|$ is written down ($\frac{n(n-1)}{2}$ numbers in total). Which number is in the $k$-th place when these numbers are sorted in non-decreasing order?
Input
The first line contains two positive integers: $n$ and $k$.
The second line contains $n$ integers $a_{i}$.
Output
One integer.
Note
$2 \le n \le 2 \cdot 10^{4}$
$1 \le k \le \frac{n(n-1)}{2}$
$0 \le a_{i} \le 10^{9}$
Examples
Input #1
4 3 1 6 3 10
Output #1
4
Input #2
2 1 5 5
Output #2
0