#C4567. Three Sum Target

    ID: 48119 Type: Default 1000ms 256MiB

Three Sum Target

Three Sum Target

Given a list of integers and an integer target, determine whether there exist three distinct integers in the list whose sum is equal to the target. More formally, given an array \(A = [a_1, a_2, \dots, a_n]\) and an integer \(T\), find if there exist indices \(i, j, k\) (with \(i < j < k\)) such that:

\[a_i + a_j + a_k = T\]

If such a triplet exists, output True, otherwise output False.

inputFormat

The input is from standard input (stdin) in the following format:

  • The first line contains an integer \(n\) (the number of elements in the array).
  • The second line contains \(n\) space-separated integers representing the array.
  • The third line contains an integer \(T\) representing the target sum.

If \(n = 0\), the second line will be empty.

outputFormat

Print to standard output (stdout) a single line with either True or False depending on whether there exists a triplet that sums to \(T\).

## sample
5
1 2 3 4 5
9
True

</p>