#C6659. Find Pairs with Exact Target Sum

    ID: 50443 Type: Default 1000ms 256MiB

Find Pairs with Exact Target Sum

Find Pairs with Exact Target Sum

In this problem, you are given the required amounts for each friend. Your task is to identify all unique pairs ((a, b)) such that (a + b = T), where (T) is the target sum provided by a wealthy donor. Each unique pair should be considered only once even if there are duplicates in the input. The input consists of the number of friends, the target sum, and then the required amounts for each friend.

Output each pair in a separate line with the two numbers separated by a space, sorted in ascending order based on the first element of the pair. If no pair exists that satisfies the condition, output "None".

inputFormat

The input is read from standard input (stdin) and is formatted as follows:

The first line contains two integers (M) and (T), separated by a space, where (M) is the number of friends and (T) is the target sum. The second line contains (M) space-separated integers representing the required amounts for each friend.

outputFormat

Output to standard output (stdout). For each unique pair that sums to (T), print a line containing the two integers separated by a space. If no such pair exists, output a single line with the string "None".## sample

5 100
40 60 10 90 50
10 90

40 60

</p>