#K81047. Find Pair with Given Sum

    ID: 35666 Type: Default 1000ms 256MiB

Find Pair with Given Sum

Find Pair with Given Sum

You are given an integer N, an array A of N integers, and a target integer T. Your task is to determine if there exists a pair of distinct indices i and j (1-indexed) such that

$$A_i + A_j = T$$

If such a pair exists, output the two indices; otherwise, output -1.

inputFormat

The input is provided via standard input (stdin). The first line contains an integer N representing the number of elements in the array. The second line contains N space-separated integers representing the array A. The third line contains the target integer T.

outputFormat

Output via standard output (stdout). If there exists a pair of distinct indices i and j (1-indexed) for which Ai + Aj = T, print the two indices separated by a space. Otherwise, print -1.## sample

5
2 7 11 15 3
9
1 2