#C6487. Pair Sum Existence

    ID: 50252 Type: Default 1000ms 256MiB

Pair Sum Existence

Pair Sum Existence

You are given an array of integers and a target integer. The task is to determine whether there exist two distinct indices i and j in the array such that the following equation holds:

\(a_i + a_j = target\)

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

This problem tests your ability to efficiently check for pair sums in an array.

inputFormat

The input begins with a single integer T on a new line, representing the number of test cases. Each test case is described as follows:

  • The first line contains an integer n indicating the number of elements in the array.
  • The second line contains n space-separated integers representing the array elements.
  • The third line contains an integer representing the target sum.

All input values are provided via stdin.

outputFormat

For each test case, output a single line containing either YES if there exists a pair of distinct indices such that the corresponding elements sum to the target, or NO if no such pair exists. The results should be printed to stdout.

## sample
3
4
2 7 11 15
9
5
1 2 3 4 5
10
6
1 2 3 4 4 5
8
YES

NO YES

</p>