#C1211. Pair Sum Problem
Pair Sum Problem
Pair Sum Problem
You are given a collection of integers and a target integer. Your task is to determine whether there exists a pair of distinct elements in the list whose sum equals the target.
Formally, given an array \(A = [a_1, a_2, \dots, a_n]\) and an integer \(T\), determine 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
.
Note: The input is given via standard input and the output should be printed to standard output.
inputFormat
The input is read from the standard input (stdin) and has the following format:
n T a1 a2 a3 ... an
Where:
n
is the number of integers in the array.T
is the target sum.- The second line contains
n
integers separated by spaces.
outputFormat
Output a single line to the standard output (stdout) containing either True
if there exists a pair of distinct elements whose sum equals the target; otherwise, output False
.
4 5
1 2 3 4
True