#C9581. Two Sum Existence
Two Sum Existence
Two Sum Existence
You are given T test cases. For each test case, you are provided with an integer n (the number of elements), a target sum x, and an array of n integers. Your task is to determine whether there exists a pair of distinct elements in the array such that their sum equals x.
This can be formally expressed as finding two indices i and j (i \neq j) such that:
$$a_i + a_j = x$$
If such a pair exists, output YES; otherwise, output NO.
inputFormat
The input is read from standard input (stdin) and has the following format:
The first line contains a single integer T (1 ≤ T ≤ 10^5), the number of test cases.
For each test case:
- The first line contains two space-separated integers n and x, where n (1 ≤ n ≤ 10^5) is the number of elements and x is the target sum.
- The second line contains n space-separated integers representing the array elements.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
outputFormat
For each test case, output a single line to standard output (stdout) containing either YES if there exists at least one pair of elements whose sum is x, or NO otherwise.## sample
3
4 5
1 2 3 4
3 10
1 1 1
5 -1
-1 0 1 2 -1
YES
NO
YES
</p>