#K85452. Pair Sum Problem
Pair Sum Problem
Pair Sum Problem
You are given an array of n integers and a target sum k. Your task is to determine whether there exists a pair of distinct elements in the array whose sum is exactly equal to k. If such a pair exists, print YES
; otherwise, print NO
.
Formally, given an array \(a\) with \(n\) elements, check if there exist indices \(i\) and \(j\) (with \(i \neq j\)) such that \(a_i + a_j = k\).
inputFormat
The input is read from stdin and consists of two lines. The first line contains two integers: (n) (the number of elements in the array) and (k) (the target sum). The second line contains (n) integers representing the elements of the array.
outputFormat
Output a single line to stdout containing YES
if there exists at least one pair of distinct elements that add up to (k), or NO
otherwise.## sample
5 9
2 7 11 15 3
YES