#C6247. Pair Sum Problem

    ID: 49986 Type: Default 1000ms 256MiB

Pair Sum Problem

Pair Sum Problem

You are given an array of integers and a target integer \( x \). Your task is to determine whether there exists a pair of distinct elements in the array whose sum equals \( x \). If such a pair exists, output "YES"; otherwise, output "NO".

Input Format: The input is read from stdin and consists of three lines. The first line contains an integer \( n \) representing the number of elements in the array. The second line contains \( n \) space-separated integers. The third line contains the target integer \( x \).

Output Format: Print a single line containing "YES" if there is at least one pair with sum equal to \( x \), otherwise print "NO".

Constraints:
\( 1 \leq n \leq 10^5 \)
The value of each array element and \( x \) can be any integer that fits in a 32-bit signed integer.

inputFormat

The first line contains an integer \( n \), the number of elements in the array. The second line contains \( n \) space-separated integers representing the array elements. The third line contains the target integer \( x \).

outputFormat

Output a single line: "YES" if there exist two distinct elements whose sum is \( x \), otherwise output "NO".

## sample
5
2 7 11 15 1
9
YES