#K12366. Two Sum Problem

    ID: 23675 Type: Default 1000ms 256MiB

Two Sum Problem

Two Sum Problem

Given an array of integers and a target integer \(T\), find two distinct indices \(i\) and \(j\) such that \(a_i + a_j = T\). It is guaranteed that each input has exactly one solution, and you may not use the same element twice.

The input is provided via standard input (stdin), and the output should be sent to standard output (stdout) in the form of two space-separated indices (0-indexed).

inputFormat

The input consists of two lines:

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

outputFormat

Output two integers separated by a space, representing the indices of the two numbers in the array that add up to \(T\). The indices are 0-indexed.

## sample
4 9
2 7 11 15
0 1