K-th Sum
Mr. Little-Z loves maths. He is given N-numbers by his teacher. He is called to find the K-th sum from all sums(consists of 2 numbers and the numbers can be same). He needs your help to solve it. Find the K-th sum.
Note : The sums are in ascending order.
InputThe first line of the standard input contains two numbers, N and K where 1<=N<=50.000 and 1<=K<=N^2. The next line contains N integers.(0<=Ai<=40.000).
OutputTo the standard output write one number that is the K-th sum.
Input:
Output:
The sums (in ascending order) are:
Sum 1: 1+1=2
Sum 2: 1+3=4
Sum 3: 3+1=4
Sum 4: 1+4=5 (this is the desired answer)
Sum 5: 4+1=5
Sum 6: 3+3=6
Sum 7: 3+4=7
Sum 8: 4+3=7
Sum 9: 4+4=8
3 4
1 3 4Output:
5The sums (in ascending order) are:
Sum 1: 1+1=2
Sum 2: 1+3=4
Sum 3: 3+1=4
Sum 4: 1+4=5 (this is the desired answer)
Sum 5: 4+1=5
Sum 6: 3+3=6
Sum 7: 3+4=7
Sum 8: 4+3=7
Sum 9: 4+4=8
Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.