#K50322. Closest Pair Sum

    ID: 28839 Type: Default 1000ms 256MiB

Closest Pair Sum

Closest Pair Sum

You are given an array of integers and an integer K. Your task is to find two unique integers from the array such that the absolute difference between their sum and K is minimized, i.e. minimize \(|a+b-K|\). It is guaranteed that the array contains at least two numbers.

The answer should be printed as two integers separated by a space. If multiple pairs have the same minimum absolute difference, the pair encountered first using the two-pointer approach on a sorted array will be selected.

inputFormat

The input is given via stdin. The first line contains two integers n and K, where n is the number of elements in the array. The second line contains n space-separated integers representing the array.

outputFormat

Output the two integers (separated by a space) whose sum is closest to K.

## sample
6 54
10 22 28 29 30 40
22 30

</p>