#K40762. Three Indices Sum Problem

    ID: 26715 Type: Default 1000ms 256MiB

Three Indices Sum Problem

Three Indices Sum Problem

You are given an array of n integers and a target integer T. Your task is to find three distinct indices i, j, and k (with 0-based indexing) such that:

ai+aj+ak=Ta_i + a_j + a_k = T

If such a triplet exists, output the three indices (in the order you find them) separated by a single space. If no such triplet exists, output -1.

Note: If there are multiple valid triplets, output the first one you encounter.

inputFormat

The input is given from the standard input with the following format:

  • The first line contains one integer n, the number of elements in the array.
  • The second line contains n space-separated integers.
  • The third line contains the target integer T.

outputFormat

If there exists a triplet of indices (i, j, k) such that a[i] + a[j] + a[k] = T, print the three indices separated by a single space. Otherwise, print -1.

## sample
6
1 2 3 4 5 6
10
0 3 4

</p>