#C4862. Pair Sum Check
Pair Sum Check
Pair Sum Check
You are given an array of integers and an integer target. Your task is to determine whether there exist two distinct elements in the array whose sum is equal to the target.
Formally, given an array \(A\) of \(n\) integers and a target integer \(T\), check if there exist indices \(i\) and \(j\) (with \(i \neq j\)) such that
\[ A_i + A_j = T \]If such a pair exists, output True
; otherwise, output False
.
inputFormat
The input is given from standard input (stdin) and consists of three lines:
- The first line contains a single integer \(n\), representing the number of elements in the array.
- The second line contains \(n\) space-separated integers, representing the elements of the array. If \(n = 0\), this line will be empty.
- The third line contains a single integer \(T\), the target sum.
It is guaranteed that \(0 \le n \le 10^5\) and each element of the array as well as the target fits in a 32-bit signed integer.
outputFormat
Output a single line to standard output (stdout) which is True
if there exists at least one pair of distinct elements in the array that sums up to the target, and False
otherwise.
4
2 7 11 15
9
True
</p>