#C6253. Three Sum Challenge

    ID: 49993 Type: Default 1000ms 256MiB

Three Sum Challenge

Three Sum Challenge

You are given a list of non-negative integers and a target value \(T\). Your task is to determine whether there exist three distinct indices \(i, j, k\) such that \(nums[i] + nums[j] + nums[k] = T\). If such a triplet exists, print "YES"; otherwise, print "NO".

Note: Each test case will be given as input from standard input (stdin) and the result should be output to standard output (stdout).

inputFormat

The input format is as follows:

  1. The first line contains an integer \(n\) representing the number of elements in the array.
  2. The second line contains \(n\) space-separated non-negative integers representing the array elements.
  3. The third line contains a single integer representing the target value \(T\).

outputFormat

Output a single line containing "YES" if there exists any triplet (with distinct indices) such that the sum of the three numbers equals \(T\); otherwise, output "NO".

## sample
5
1 2 3 4 5
9
YES

</p>