#C2789. Find a Pair with a Given Sum

    ID: 46143 Type: Default 1000ms 256MiB

Find a Pair with a Given Sum

Find a Pair with a Given Sum

You are given an array of n integers and an integer x. Your task is to find two distinct elements in the array such that their sum is equal to x. If there are multiple valid pairs, you can output any one of them. If no such pair exists, print -1.

More formally, given an array \(A\) of length \(n\) and an integer \(x\), find two numbers \(a\) and \(b\) (with \(a \neq b\)) from \(A\) such that \(a + b = x\). If such numbers exist, output them (order does not matter). Otherwise, output \(-1\).

The input will be read from standard input and the output should be printed to standard output.

inputFormat

The input consists of two lines:

  1. The first line contains two integers \(n\) and \(x\), where \(n\) is the number of integers in the array and \(x\) is the target sum.
  2. The second line contains \(n\) space-separated integers representing the array \(A\).

outputFormat

If there exists a pair \((a, b)\) such that \(a + b = x\), output the two numbers separated by a space (order does not matter). If no such pair exists, output \(-1\).

## sample
5 9
2 7 11 15 1
2 7

</p>