#C6578. Triplet Sum

    ID: 50353 Type: Default 1000ms 256MiB

Triplet Sum

Triplet Sum

You are given an array of integers and an integer target, T. Your task is to determine whether there exists a triplet (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 provided from standard input in two lines:

  • The first line contains two integers, n and T, where n is the number of elements in the array and T is the target sum.
  • The second line contains n space-separated integers representing the elements of the array.

outputFormat

Print a single line to standard output: True if there exists any triplet in the array whose sum equals T; otherwise, print False.## sample

6 24
12 3 4 1 6 9
True