#K64372. Check Pair Sum
Check Pair Sum
Check Pair Sum
You are given an integer (T) representing the number of test cases. For each test case, you are given an integer (n) (the number of elements in the array), an integer (x) (the target sum), and an array of (n) integers. Your task is to determine whether there exists a pair of distinct integers (a) and (b) in the array such that (a+b=x). If such a pair exists, print YES
for that test case; otherwise, print NO
.
For example, if the target sum is (x=10) and the array is [1, 2, 3, 5, 5], the answer is YES
since (5+5=10).
Note: The input is read from standard input (stdin) and output is written to standard output (stdout).
inputFormat
The first line of input contains a single integer (T), the number of test cases. Each test case is described as follows:
- The first line contains two integers (n) and (x), where (n) is the number of elements in the array and (x) is the target sum.
- If (n > 0), the next line contains (n) space-separated integers, representing the elements of the array.
It is guaranteed that (0 \leq n \leq 10^5) and the sum of all (n) over all test cases does not exceed (10^5).
outputFormat
For each test case, output a single line containing either YES
or NO
. The output should be printed to standard output (stdout).## sample
3
5 10
1 2 3 5 5
4 8
2 2 2 2
6 7
1 2 3 4 3 4
YES
NO
YES
</p>