#C5864. Two Sum Problem

    ID: 49560 Type: Default 1000ms 256MiB

Two Sum Problem

Two Sum Problem

You are given an array of integers and a target value. Your task is to find two distinct indices i and j such that:

$$nums[i] + nums[j] = target$$

If such a pair exists, output the indices in the order in which they appear in the array. Otherwise, output -1.

inputFormat

The input is provided via stdin in the following format:

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

outputFormat

Output via stdout a single line. If a valid pair is found, print the two indices separated by a space; otherwise, print -1.## sample

4
2 7 11 15
9
0 1

</p>