#K12911. Pair with Target Sum
Pair with Target Sum
Pair with Target Sum
Given a list of integers and a target sum \( x \), determine whether there exist two distinct numbers in the list that add up to \( x \). This problem requires you to implement an efficient solution that works in linear time on average.
Task: Write a program that reads the number of integers and the target sum in the first line, and then the list of integers in the second line, and outputs "YES" if there exists a pair that sums to \( x \) and "NO" otherwise.
Example:
Input: 5 8 1 2 3 4 5</p>Output: YES
inputFormat
The first line contains two space-separated integers \( n \) and \( x \), where \( n \) is the number of integers in the list and \( x \) is the target sum.
The second line contains \( n \) space-separated integers.
outputFormat
Output a single line containing "YES" if there exists a pair of distinct integers that add up to \( x \), otherwise output "NO".
## sample5 8
1 2 3 4 5
YES
</p>