#C3501. Two Sum Problem
Two Sum Problem
Two Sum Problem
You are given an array of integers and a target integer. Your task is to find two distinct indices in the array such that the corresponding numbers add up to the given target.
If such a pair exists, output the 1-indexed positions of the two numbers separated by a single space. If no such pair exists, output -1.
The solution should use input from standard input (stdin) and print the result to standard output (stdout).
Note: Each array element can be used at most once and the first valid pair found should be output.
inputFormat
The first line contains two integers n and target, where n is the number of elements in the array, and target is the sum to be achieved.
The second line contains n space-separated integers representing the array elements.
outputFormat
If a valid pair is found, output two integers representing their 1-indexed positions, separated by a space. Otherwise, output -1.
## sample4 9
2 7 11 15
1 2