#K15196. Find Two Sum Indices

    ID: 24303 Type: Default 1000ms 256MiB

Find Two Sum Indices

Find Two Sum Indices

Given an array (A) of (n) integers and a target sum (t), your task is to find two distinct indices (i) and (j) (1-indexed) such that (A_i + A_j = t). If such a pair exists, output the indices separated by a space; otherwise, output (-1).

Note: If multiple pairs exist, printing any valid pair is acceptable.

inputFormat

The input is given via standard input:\ The first line contains two integers (n) and (t) -- the number of elements and the target sum respectively.\ The second line contains (n) space-separated integers representing the array (A).

outputFormat

Output to standard output: if a valid pair is found, print two integers (i) and (j) separated by a space, representing the 1-indexed positions of the elements whose sum equals (t). If no valid pair exists, print (-1).## sample

5 9
2 7 11 15 1
1 2