#K57512. Pair Sum Existence Problem
Pair Sum Existence Problem
Pair Sum Existence Problem
We are given an array of n integers and a target integer, ( T ). The goal is to determine whether there exist two distinct elements in the array that sum up to ( T ). In other words, we want to check if there exists a pair ( (a_i, a_j) ) with ( i \neq j ) such that ( a_i + a_j = T ).
Input will be read from standard input and output printed to standard output.
inputFormat
The first line contains two space-separated integers: ( n ) (the number of elements in the array) and ( T ) (the target sum). The second line contains ( n ) space-separated integers, representing the elements of the array.
outputFormat
Output a single line with the string "YES" if there exists a pair of distinct indices ( i ) and ( j ) such that the sum of the corresponding elements is equal to ( T ); otherwise output "NO".## sample
5 9
2 7 11 15 4
YES