#K47552. Pair Sum Special Number

    ID: 28223 Type: Default 1000ms 256MiB

Pair Sum Special Number

Pair Sum Special Number

You are given a list of integers \(K = [k_1, k_2, \ldots, k_n]\) and a set of queries. For each query \(q\), your task is to determine whether there exist two distinct integers from the list such that their sum is exactly \(q\). In other words, check if there exist indices \(i, j\) with \(i \neq j\) satisfying

[ k_i + k_j = q, ]

If such a pair exists, output YES; otherwise output NO for that query.

Note: Although the problem statement might suggest using "two or more distinct integers", you are only required to check for the existence of a pair \( (k_i, k_j) \) whose sum equals \(q\).

inputFormat

The input is given from standard input (stdin) in the following format:

 n
 k1 k2 ... kn
 m
 q1 q2 ... qm

Where:

  • n is the number of integers in the list \(K\).
  • Next line contains \(n\) integers separated by spaces.
  • m is the number of queries.
  • The next line contains \(m\) query integers.

outputFormat

For each query, print a line with either YES if there exists a pair whose sum is equal to the query value, or NO otherwise. The output should be written to standard output (stdout), one result per line.

## sample
5
1 2 3 5 8
3
8 15 7
YES

NO YES

</p>