#C3895. Find Pair with Given Sum
Find Pair with Given Sum
Find Pair with Given Sum
You are given a list of integers and an integer k. Your task is to find a pair of distinct numbers from the list that add up exactly to k. If multiple such pairs exist, choose the pair with the smallest first number. If there is still a tie, choose the one with the smallest second number. Note that the pair should be determined after removing any duplicate values from the list. If no such pair exists, output -1.
Input Example:
7 5 1 2 3 4 3 2 1
Output Example:
1 4
Note: The input is read from stdin and the output is printed to stdout.
inputFormat
The first line of input contains two integers n and k, where n is the number of elements in the list and k is the target sum. The second line contains n space-separated integers representing the list.
If n is 0, then the list is empty.
outputFormat
If a valid pair is found, print the two numbers separated by a space. Otherwise, print -1. The pair printed should be the one with the smallest first number and, in case of tie, the smallest second number.
## sample7 5
1 2 3 4 3 2 1
1 4