#C432. Unique Pairs Sum

    ID: 47845 Type: Default 1000ms 256MiB

Unique Pairs Sum

Unique Pairs Sum

Given an array of (n) integers and a target sum (T), your task is to find all unique pairs of numbers ((a, b)) such that (a + b = T). Each pair ((a, b)) must satisfy (a \leq b) and the pairs should be printed in lexicographical order. Note that each pair should appear only once regardless of how many times the numbers appear in the array.

For example, if the input array is [1, 3, 5, 7, 9, 2] and (T = 10), the valid pairs are ((1, 9)) and ((3, 7)) since (1+9 = 10) and (3+7 = 10).

inputFormat

The first line contains two integers (n) and (T) where (n) is the number of elements in the array and (T) is the target sum. The second line contains (n) space-separated integers.

outputFormat

For each unique pair ((a, b)) such that (a + b = T), output a line with two integers (a) and (b) separated by a space. The pairs must be ordered in lexicographical order. If no such pair exists, output nothing.## sample

6 10
1 3 5 7 9 2
1 9

3 7

</p>