#C2141. Two Sum Check
Two Sum Check
Two Sum Check
You are given an array of n distinct integers and a target integer t. Your task is to determine whether there exist two different elements in the array whose sum equals t. More formally, find two indices i and j with i \neq j such that
\(a_i + a_j = t\)
If such a pair exists, print YES
. Otherwise, print NO
.
Note: The input is given via standard input (stdin) and the output should be written to standard output (stdout).
inputFormat
The first line contains two integers n
and t
, where n
is the number of elements in the array and t
is the target sum.
The second line contains n
space-separated integers representing the elements of the array.
Constraints: The numbers in the array are distinct.
outputFormat
Output a single line containing YES
if there exist two distinct numbers in the array whose sum equals t
, otherwise output NO
.
5 9
2 7 11 15 1
YES