K-th Smallest Element

5

1 votes
Binary Search, Arrays, Sorting
Problem

Given an array A of N integers. Using this array you create a new set S which contains all possible value A[i]+A[j](1ijn).

Your task is to find the Kth smallest element in this set.

Constraints:

1N2000001A[i]100000001KN(N+1)2

Input:

The first line of the input contains N - the size of the array and K.

Second-line contains N integers A1,A2,...An.

Output:

Print the Kth smallest element.

Sample Input
4 5
2 3 4 5
Sample Output
7
Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

Here the set S = [4,5,6,6,7,7,8,8,9]

so the 5th smallest element is 7.

Contributers:
Editor Image

?