#C5731. Triplet Sum Finder

    ID: 49413 Type: Default 1000ms 256MiB

Triplet Sum Finder

Triplet Sum Finder

Given an array of positive integers and a target sum T, determine whether there exist three distinct elements in the array such that their sum equals T. In other words, find if there exist indices i, j, and k (all different) such that

\(a_i + a_j + a_k = T\)

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

inputFormat

The input consists of three lines:

  • The first line contains an integer N (N ≥ 1) representing the number of elements in the array.
  • The second line contains N space-separated positive integers, the elements of the array.
  • The third line contains a single integer T, the target sum.

outputFormat

Output a single line with either True if there exist three distinct elements whose sum equals T, or False otherwise.

## sample
6
1 4 45 6 10 8
22
True