#K60197. Find Pair With Sum

    ID: 31033 Type: Default 1000ms 256MiB

Find Pair With Sum

Find Pair With Sum

Given an array of integers and a target sum \(T\), your task is to find two distinct indices \(i\) and \(j\) (with \(i \neq j\)) such that the sum of the corresponding elements equals \(T\); that is, \(a_i + a_j = T\). If such a pair exists, output the two indices (0-indexed) separated by a space. Otherwise, output -1.

Note: If there are multiple solutions, output the one that appears first based on the array’s order.

inputFormat

The input is given via standard input and consists of three lines:

  • The first line contains a single integer \(n\), the number of elements in the array.
  • The second line contains \(n\) space-separated integers, representing the elements of the array.
  • The third line contains a single integer \(T\), the target sum.

outputFormat

Print to standard output. If a valid pair exists, output the two indices separated by a space. If no such pair exists, print -1.

## sample
5
1 2 3 4 5
6
1 3