#C14210. Find Unique Pairs That Sum to k

    ID: 43835 Type: Default 1000ms 256MiB

Find Unique Pairs That Sum to k

Find Unique Pairs That Sum to k

Given an array of integers \(nums\) and an integer \(k\), your task is to find all unique pairs \((x, y)\) such that \(x + y = k\) and \(x < y\). Each pair should be returned in the form \((x, y)\) with the smaller number first. The final result must be a sorted list of pairs (sorted primarily by the first element and then by the second element).

Example: For \(nums = [1, 2, 3, 4]\) and \(k = 5\), the unique pairs are \((1, 4)\) and \((2, 3)\), so the output should be [(1, 4), (2, 3)].

Note: All input is read from standard input and output should be written to standard output.

inputFormat

The input consists of three lines:

  1. The first line contains an integer \(n\), representing the number of elements in the array.
  2. The second line contains \(n\) space-separated integers.
  3. The third line contains the integer \(k\).

outputFormat

Output the list of unique pairs in a Python-style list format. Each pair should be displayed as \((x, y)\) with a comma and a space between them, and pairs should be separated by a comma and a space. For example: [(1, 4), (2, 3)].

## sample
4
1 2 3 4
5
[(1, 4), (2, 3)]