#C10852. Find Pair with Target Sum

    ID: 40103 Type: Default 1000ms 256MiB

Find Pair with Target Sum

Find Pair with Target Sum

You are given an array of integers and a target integer \( k \). Your task is to determine whether there exist two distinct numbers \( a_i \) and \( a_j \) in the array such that \( a_i + a_j = k \).

If such a pair exists, print YES, otherwise print NO.

The input begins with a number indicating the number of test cases. Each test case consists of two lines. The first line contains two integers: the size of the array \( n \) and the target sum \( k \). The second line contains \( n \) space-separated integers representing the array.

You need to solve this problem efficiently.

inputFormat

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

  • The first line contains two space-separated integers: \( n \) (the number of elements in the array) and \( k \) (the target sum).
  • The second line contains \( n \) space-separated integers denoting the array.

All input should be read from standard input (stdin).

outputFormat

For each test case, output a single line containing either YES if there exists a pair of distinct elements whose sum equals \( k \), or NO otherwise.

All output should be written to standard output (stdout).

## sample
1
5 9
2 7 11 15 1
YES

</p>