#C13240. Find Pair with Given Sum

    ID: 42757 Type: Default 1000ms 256MiB

Find Pair with Given Sum

Find Pair with Given Sum

You are given a list of integers and a target integer (T). Your task is to determine whether there exist two distinct numbers in the list whose sum equals (T).

If such a pair exists, output the two numbers separated by a space, where the first number is the one that was seen earlier in the list. Otherwise, output (-1).

For example, given the list [1, 2, 3, 4] and (T = 5), the correct output is "2 3" because 2 is encountered before 3 and (2 + 3 = 5).

inputFormat

The input is given via standard input in the following format:
1. The first line contains an integer (n), the number of elements in the list.
2. The second line contains (n) integers separated by spaces.
3. The third line contains an integer (T), the target sum.

outputFormat

Print the two numbers (separated by a space) that sum to (T) if such a pair exists. If no such pair exists, print (-1).## sample

4
1 2 3 4
5
2 3

</p>