#C320. Pair with Sum

    ID: 46601 Type: Default 1000ms 256MiB

Pair with Sum

Pair with Sum

Given an array of integers and an integer (k), determine whether there exist two distinct indices (i) and (j) such that (a_i + a_j = k). More formally, given an array ({a_1, a_2, \ldots, a_n}) and an integer (k), check if there exist indices (i \neq j) satisfying (a_i + a_j = k). This problem tests your ability to use efficient lookup techniques to solve the two-sum problem.

inputFormat

The input is given via standard input (stdin) and consists of two lines. The first line contains two space-separated 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 to standard output (stdout): print true if there exists a pair of distinct elements whose sum is equal to (k), otherwise print false.## sample

4 17
10 15 3 7
true