#K90107. Two Sum Indices
Two Sum Indices
Two Sum Indices
Given a list of integers and a target integer \(T\), determine if there exists a pair of distinct elements in the list whose sum equals \(T\). If such a pair exists, output their indices (the first index encountered and the corresponding index that completes the sum); otherwise, output -1.
For example, if the list is [2, 7, 11, 15, 5] and \(T = 9\), since 2 + 7 = 9, you should output: 0 1
.
The indices should be output in the order in which the solution is found. Each test input will contain the size of the list, the list of integers, and the target number.
inputFormat
The input is read from standard input (stdin) and is formatted as follows:
- The first line contains a single integer \(n\) representing the number of elements in the list.
- The second line contains \(n\) space-separated integers representing the list elements.
- The third line contains a single integer representing the target \(T\).
outputFormat
Output to standard output (stdout) a single line containing two space-separated integers representing the indices of the two numbers whose sum equals \(T\). If no such pair exists, output -1.
## sample5
2 7 11 15 5
9
0 1