10267: CF EDU - Binary Search - Step 5 - C. K-th Sum
[Creator : ]
Description
There are two arrays $a$ and $b$, each of which consists of $n$ integers. For each pair of numbers $(i,j):1≤i,j≤n$, write out the sum $a_i+b_j$. Find in the resulting set of sums the $k$-th in ascending order.
Input
The first line contains integers $n,k\ (1≤n≤10^5,\ 1≤k≤n^2)$.
The second line contains the elements of array $a$,
the third line contains the elements of array $b$.
All array elements are positive integers, no more than $10^9$.
Output
Print one number, the required $k$-th sum.
Sample 1 Input
5 10
4 2 6 4 8
7 3 1 9 5
Sample 1 Output
9