#C2866. Pair Sum Problem
Pair Sum Problem
Pair Sum Problem
Given an integer sequence \(a_1, a_2, \dots, a_n\) and an integer \(k\), your task is to determine whether there exist two distinct indices \(i\) and \(j\) (with \(i \neq j\)) such that \(a_i + a_j = k\). If such a pair exists, output "YES"; otherwise, output "NO".
Note: Read input from stdin
and write the result to stdout
.
inputFormat
The first line contains two integers (n) and (k), where (n) is the number of elements in the array and (k) is the target sum. The second line contains (n) space-separated integers representing the array.
outputFormat
Output a single line containing "YES" if there exist two distinct elements whose sum equals (k); otherwise, output "NO".## sample
5 9
2 7 11 15 1
YES
</p>