#C11579. Unique Pairs with Target Sum
Unique Pairs with Target Sum
Unique Pairs with Target Sum
You are given a list of integers and a target integer. Your task is to find all unique pairs ((a, b)) such that (a + b = \text{target}). For each valid pair, ensure that (a \le b). The list of resulting pairs must then be sorted in ascending order first by (a) and then by (b).
For example, given the list [1, 2, 3, 4, 3, 6] and (\text{target} = 6), the unique pairs are [(2, 4), (3, 3)]
. If there are no pairs that satisfy the condition, output an empty list []
.
inputFormat
Input is read from standard input (stdin). The first line contains two integers: (n) (the number of elements) and (\text{target}). The second line contains (n) space-separated integers representing the list of numbers.
outputFormat
Print the resulting list of unique pairs to standard output (stdout) in the format: [(a, b), (c, d), ...]
. If no valid pair exists, print []
.## sample
6 6
1 2 3 4 3 6
[(2, 4), (3, 3)]