#K90812. Taco Sum Pair
Taco Sum Pair
Taco Sum Pair
You are given an array of integers and a target integer k. Your task is to determine whether there exist two distinct elements in the array such that their sum is exactly equal to k. In mathematical terms, you need to decide if there exist indices i and j with i \neq j such that:
$$ arr[i] + arr[j] = k $$
If such a pair exists, output YES
; otherwise, output NO
.
Note: The input is given via standard input and the answer should be printed to standard output.
inputFormat
The input consists of three lines:
- The first line contains a single integer n which represents the number of elements in the array.
- The second line contains n space-separated integers representing the array elements.
- The third line contains a single integer k, the target sum.
outputFormat
Output a single line containing YES
if there exists a pair of distinct elements whose sum is exactly equal to k, otherwise output NO
.
5
1 2 3 4 5
9
YES