#C8296. Find Unique Pairs with a Given Sum

    ID: 52262 Type: Default 1000ms 256MiB

Find Unique Pairs with a Given Sum

Find Unique Pairs with a Given Sum

You are given an array of integers and a target value. Your task is to find all unique pairs (a, b) from the array such that \(a+b=\text{target}\).

Each pair should be output in sorted order (i.e. the smaller number first) and the list of pairs should be sorted lexicographically (first by the first element, then by the second element).

If no such pair exists, output None.

Note: Each pair is considered unique, so even if there are multiple occurrences of the numbers, each qualifying pair should only be printed once.

inputFormat

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

outputFormat

For each unique pair that sums to (target), output a line with the two numbers separated by a space. The pairs must be printed in ascending order. If no pair exists, output a single line with the word "None".## sample

6 10
1 2 3 4 5 6
4 6