#C5058. Target Sum Pairs
Target Sum Pairs
Target Sum Pairs
You are given an array of integers and a target integer \(T\). Your task is to find all unique pairs \((a, b)\) from the array such that \(a + b = T\) and \(a \le b\). The resulting pairs must be output in ascending order (first by the first element then by the second element). If no such pair exists, do not output anything.
Note: Each pair should appear only once even if there are duplicates in the input, and the order of pairs must be sorted.
inputFormat
The input is given via standard input and has the following format:
- The first line contains an integer \(n\), the number of elements in the array.
- The second line contains \(n\) space-separated integers representing the array elements.
- The third line contains the target integer \(T\).
It is guaranteed that \(n \ge 0\) and the integers fit into a 32-bit signed integer.
outputFormat
Output each unique pair on a separate line. Each line should contain two integers separated by a single space (the smaller number first). The pairs must be printed in ascending order. If there is no pair that adds up to \(T\), output nothing.
## sample7
2 4 3 3 5 -1 1
4
-1 5
1 3
</p>