#C9569. Pair Sum Finder

    ID: 53676 Type: Default 1000ms 256MiB

Pair Sum Finder

Pair Sum Finder

You are given an array of n integers and a target integer T. Your task is to determine if there exists a pair of distinct indices i and j such that the sum of the corresponding elements is exactly T. Formally, find if there exists two indices i and j (with i ≠ j) satisfying

\(a_i + a_j = T\)

If such a pair exists, print YES; otherwise, print NO.

Note: The input is provided via standard input and the output should be printed to standard output.

inputFormat

The input is given in two lines. The first line contains two space-separated integers: n (the number of elements) and T (the target sum). The second line contains n space-separated integers representing the array elements.

outputFormat

Output a single line containing either YES if there exists at least one pair of distinct indices i and j such that (a_i + a_j = T), or NO otherwise.## sample

5 9
2 7 11 15 1
YES