#K1256. Pair with Target Sum
Pair with Target Sum
Pair with Target Sum
In this problem, you are given an array of integers and a target integer (K). Your task is to determine if there are any two distinct numbers in the array that add up to (K). If such a pair exists, output "YES"; otherwise, output "NO".
Input Format:
- The first line contains a single integer (n), denoting the number of elements in the array.
- The second line contains (n) space-separated integers, representing the array elements.
- The third line contains the integer (K), the target sum.
Output Format:
- Output a single line with "YES" if a valid pair exists, or "NO" otherwise.
inputFormat
The input is read from standard input (stdin) and consists of three lines:
- An integer (n), representing the number of elements in the array.
- (n) space-separated integers representing the array elements.
- An integer (K) denoting the target sum.
outputFormat
Output a single line to standard output (stdout) containing "YES" if there exists any two distinct numbers in the array whose sum equals (K), otherwise output "NO".## sample
5
2 4 5 1 6
9
YES