#C5846. Find a Pair with Given Sum
Find a Pair with Given Sum
Find a Pair with Given Sum
You are given an array of integers A and an integer T (target). Your task is to find two distinct numbers x and y from the array such that
$$ x + y = T $$
If there are multiple correct pairs, you may output any one of them. If no such pair exists, output No Solution
.
The solution should read the input from stdin
and write the answer to stdout
. When a valid pair is found, output the two numbers separated by a single space. The order of the numbers should correspond to their appearance in the input.
inputFormat
The input is given from stdin
and has the following format:
- The first line contains two integers n and T where n is the number of elements in the array and T is the target sum.
- The second line contains n integers, representing the elements of the array, separated by spaces.
outputFormat
If a pair is found, output the two integers separated by a space. If no valid pair exists, output No Solution
.
4 9
2 7 11 15
2 7
</p>