#K46437. Pair Sum Problem

    ID: 27976 Type: Default 1000ms 256MiB

Pair Sum Problem

Pair Sum Problem

You are given an array of integers and a target integer. Your task is to determine whether there exists a pair of distinct elements in the array whose sum is equal to the target. In other words, you need to check if there exist indices ii and jj such that iji \neq j and $$a_i + a_j = \text{target}.$$ If such a pair exists, print Yes; otherwise, print No.

Note: The array may be empty or contain negative numbers.

inputFormat

The first line of input contains an integer nn representing the number of elements in the array. The second line contains nn space-separated integers representing the array elements. The third line contains an integer representing the target sum.

outputFormat

Output a single line with Yes if there exists a pair of distinct elements whose sum is equal to the target, and No otherwise.## sample

5
2 7 11 15 3
9
Yes