#K4486. Two Sum Existence Problem

    ID: 27625 Type: Default 1000ms 256MiB

Two Sum Existence Problem

Two Sum Existence Problem

Given an array of integers and a target value \(T\), determine whether there exist two distinct indices \(i\) and \(j\) in the array such that \(a_i + a_j = T\). Output YES if such a pair exists; otherwise, output NO.

inputFormat

The input is provided via standard input. The first integer \(n\) represents the number of elements in the array. The next \(n\) integers are the elements of the array, followed by an integer \(T\) representing the target value.

outputFormat

Print a single line containing the string YES if there exists a pair of distinct indices \(i\) and \(j\) such that \(a_i + a_j = T\); otherwise, print NO.

## sample
5
2 7 11 15 3
9
YES