#K811. Find Pair with Given Sum
Find Pair with Given Sum
Find Pair with Given Sum
You are given a list of n integers and a target integer T. Your task is to determine whether there exists a pair of distinct elements in the list whose sum is exactly equal to T. If such a pair exists, output "YES"; otherwise, output "NO".
Note: Each test case is independent and the input is read from standard input (stdin) while the output should be printed to standard output (stdout).
The solution should work efficiently even for large inputs.
inputFormat
The input is provided via stdin and consists of two lines:
- The first line contains two space-separated integers:
n
(the number of elements in the list) andT
(the target sum). - The second line contains
n
space-separated integers representing the list elements.
outputFormat
Output a single line with the string "YES" if there exists any pair of distinct elements whose sum equals T, otherwise output "NO".
## sample5 9
1 2 3 4 5
YES