#K59037. Pair with Given Sum

    ID: 30775 Type: Default 1000ms 256MiB

Pair with Given Sum

Pair with Given Sum

Given an array of N integers and a target integer K, determine if there exist two distinct elements ai and aj in the array such that their sum is exactly K. In other words, find if there exist indices i < j satisfying

$$a_i + a_j = K$$

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

Your solution should read input from standard input (stdin) and print the result to standard output (stdout).

inputFormat

The input consists of two lines:

  • The first line contains two integers N and K, where N is the number of elements in the array and K is the target sum.
  • The second line contains N space-separated integers representing the elements of the array.

outputFormat

Output a single line containing YES if there exists a pair of distinct elements whose sum is equal to K, and NO otherwise.

## sample
5 9
2 7 11 15 3
YES