#C9259. Find Pair With Sum

    ID: 53332 Type: Default 1000ms 256MiB

Find Pair With Sum

Find Pair With Sum

Given an integer \(X\) and an array \(A\) of \(N\) integers, determine whether there exist two distinct indices \(i\) and \(j\) such that \(A[i] + A[j] = X\). You are given \(T\) test cases.

For each test case, output YES if such a pair exists and NO otherwise.

Note: It is required that the indices are distinct (i.e. \(i \neq j\)).

inputFormat

The input is read from standard input (stdin). The first line contains an integer (T), indicating the number of test cases. For each test case, the first line contains an integer (N) (the number of elements in the array). The second line contains (N) space-separated integers representing the array (A). The third line contains the target integer (X).

outputFormat

For each test case, print a single line to standard output (stdout) containing either YES if there exist two distinct indices (i) and (j) such that (A[i] + A[j] = X), or NO if no such pair exists.## sample

3
5
1 2 3 4 5
7
4
0 -1 2 3
2
3
1 3 5
10
YES

YES NO

</p>