#K44177. Difference Pair Existence

    ID: 27474 Type: Default 1000ms 256MiB

Difference Pair Existence

Difference Pair Existence

You are given an array of integers and an integer \(k\). Your task is to determine whether there exists at least one pair of elements in the array such that the difference between them is exactly \(k\). Formally, for an array \(A\) of size \(n\), you need to check if there exists any element \(a\) in \(A\) for which at least one of the conditions below holds:

\(a + k \in A\) or \(a - k \in A\).

Note: In this problem, even if \(k = 0\), the condition is checked in the same way. This means that if the array is non-empty, the condition will trivially be true since \(a \in A\) for any \(a\). Please follow the input and output format strictly.

inputFormat

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

  1. The first line of each test case contains two integers \(n\) and \(k\), where \(n\) is the number of elements in the array and \(k\) is the target difference.
  2. The second line contains \(n\) space-separated integers representing the elements of the array.

The input is read from standard input (stdin).

outputFormat

For each test case, output a single line containing either YES if there exists at least one pair of elements with difference \(k\), or NO otherwise. The output must be written to standard output (stdout).

## sample
3
5 2
1 5 3 4 2
4 0
1 2 3 4
4 10
100 200 150 80
YES

YES NO

</p>