#C5389. Two Sum Indices

    ID: 49032 Type: Default 1000ms 256MiB

Two Sum Indices

Two Sum Indices

Given an array of integers and a target value \(T\), your task is to find two distinct indices \(i\) and \(j\) (with \(i < j\)) such that \(nums[i] + nums[j] = T\). If such a pair exists, output the indices separated by a space. Otherwise, output -1.

Note: The solution must read from stdin and write the result to stdout.

For example:

  • Input: 5\n2 7 11 15 1\n9 → Output: 0 1
  • Input: 4\n1 2 3 4\n8 → Output: -1

inputFormat

The input is given on standard input (stdin) in the following format:

  1. The first line contains an integer \(n\), the number of elements in the array.
  2. The second line contains \(n\) space-separated integers representing the array \(nums\).
  3. The third line contains an integer \(T\), the target sum.

outputFormat

Print to standard output (stdout) the two indices \(i\) and \(j\) (where \(i < j\)) separated by a space if a valid pair exists. Otherwise, print -1.

## sample
5
2 7 11 15 1
9
0 1

</p>