#C11032. Triplet Sum Problem

    ID: 40304 Type: Default 1000ms 256MiB

Triplet Sum Problem

Triplet Sum Problem

Given an array of integers and a target value \(T\), determine if there exist three distinct indices \(i, j, k\) such that \(nums[i] + nums[j] + nums[k] = T\). If such a triplet exists, output Yes; otherwise, output No.

The input starts with an integer representing the number of elements in the array, followed by the elements of the array, and finally the target integer.

inputFormat

The first integer is \(n\), the number of elements in the array. The next \(n\) integers are the array elements, and the last integer is the target value \(T\).

outputFormat

Output a single line containing "Yes" if there exists a triplet of numbers whose sum equals \(T\), otherwise output "No".

## sample
5 1 2 3 4 5 9
Yes