#C12098. Find Pair with Target Sum

    ID: 41487 Type: Default 1000ms 256MiB

Find Pair with Target Sum

Find Pair with Target Sum

You are given a list of integers and a target integer. Your task is to find two distinct integers in the list whose sum is exactly equal to the target. If such a pair exists, output the two numbers separated by a single space; otherwise, print None.

Note: If there are multiple possible pairs, output the pair found first using a left-to-right scanning approach. The input is given via standard input and output via standard output.

The problem can be formally described by the formula:

Find numbers \(a, b\) from list \(L\) such that \(a + b = T\), where \(T\) is the target.

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 representing the elements of the array.
  3. The third line contains an integer representing the target sum \(T\).

outputFormat

If there exists a pair of distinct numbers that add up to the target sum, output the two numbers separated by a space. If no such pair exists, output None.

## sample
4
2 7 11 15
9
2 7

</p>