#K50387. Pair with Sum
Pair with Sum
Pair with Sum
Given an array of integers and an integer \( k \), determine whether there exists a pair of distinct elements in the array such that their sum equals \( k \). More formally, you are to check if there exist indices \( i \) and \( j \) with \( i \neq j \) such that \( a_i + a_j = k \). This problem tests your ability to efficiently search for pairs that meet a specific criterion.
inputFormat
The input is given via standard input in the following format:
- The first line contains an integer \( n \) representing the number of elements in the array.
- The second line contains \( n \) integers separated by spaces — the elements of the array.
- The third line contains a single integer \( k \), the target sum.
outputFormat
Output a single line to standard output which is either "YES" if there exists a pair of distinct elements whose sum equals \( k \), or "NO" otherwise.
## sample6
1 4 45 6 10 8
16
YES