#K79527. Pair with Target Sum

    ID: 35328 Type: Default 1000ms 256MiB

Pair with Target Sum

Pair with Target Sum

Given an integer k and an array of n integers, determine whether there exists a pair of distinct elements in the array whose sum is exactly k. If such a pair exists, print "YES"; otherwise, print "NO".

Constraints:

  • Each test case begins with two integers, \(n\) (the number of elements) and \(k\) (the target sum).
  • The following line contains \(n\) space-separated integers representing the array.
  • You may assume that the numbers fit within standard integer data types.

Example:

Input:
1
5 9
1 2 3 4 5

Output: YES

</p>

inputFormat

The first line of input contains an integer T denoting the number of test cases. Each test case consists of two lines:

  • 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

For each test case, output a single line with the string "YES" if there exists a pair of distinct elements whose sum equals \(k\), or "NO" if no such pair exists.

## sample
1
5 9
1 2 3 4 5
YES

</p>