#C1723. Find Two Sum Indices

    ID: 44960 Type: Default 1000ms 256MiB

Find Two Sum Indices

Find Two Sum Indices

In this problem, you are given an array of integers and a target integer (T). Your task is to find two distinct indices (i) and (j) (with (i < j)) such that the sum of the elements at these indices equals the target, i.e. (a[i] + a[j] = T). If such a pair exists, print the indices; otherwise, print -1. The array indices start from 0. This problem requires that you read the input from standard input and produce the output to standard output.

inputFormat

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

outputFormat

If there exists a pair of indices (i, j) (with (i < j)) such that (a[i] + a[j] = T), output the two indices separated by a space. Otherwise, print -1.## sample

6
2 7 11 15 -1 8
9
0 1