#C11421. Two Sum Problem

    ID: 40736 Type: Default 1000ms 256MiB

Two Sum Problem

Two Sum Problem

You are given an array of integers and a target value \(T\). Your task is to find the indices of the two numbers in the array that add up to the target \(T\). If no such pair exists, output \(-1 -1\).

The input begins with two integers \(n\) and \(T\), where \(n\) is the number of elements in the array. The next line contains \(n\) integers separated by spaces.

Note: The indices are 0-based. If multiple valid pairs exist, return the first pair found when scanning from left to right.

inputFormat

The input is given via standard input (stdin) with the following format:

  • The first line contains two integers \(n\) and \(T\): the number of elements and the target sum.
  • The second line contains \(n\) space-separated integers representing the array.

outputFormat

Output two space-separated integers to standard output (stdout) representing the indices of the two numbers that add up to \(T\). If no valid pair exists, output "-1 -1".

## sample
4 9
2 7 11 15
0 1

</p>