#K14966. Two Sum Indices

    ID: 24252 Type: Default 1000ms 256MiB

Two Sum Indices

Two Sum Indices

Given an array of integers and a target integer \(T\), your task is to find two distinct indices \(i\) and \(j\) in the array such that the sum \(a[i] + a[j] = T\). If no such pair exists, output -1 -1. The indices are 0-based.

Note: If there are multiple valid pairs, output the first one found following the order of traversal.

inputFormat

The input is provided via standard input (stdin) in the following format:

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

outputFormat

Print two space-separated integers on a single line representing the indices \(i\) and \(j\). If no valid pair exists, print -1 -1.

## sample
4
2 7 11 15
9
0 1