#K94962. Combination Sum II

    ID: 38758 Type: Default 1000ms 256MiB

Combination Sum II

Combination Sum II

You are given an array of integers and a target value. Your task is to find all unique combinations in the array where the chosen numbers sum up to the given target. Each number in the array may be used at most once in each combination. The combination is defined as a subset \( S \) such that \( \sum_{a \in S} a = target \). The solution set should not contain duplicate combinations.

Note: The order of numbers in a combination does not matter, but the combinations themselves must be output in lexicographically increasing order.

inputFormat

The input is read from standard input (stdin) and has the following format:

n
num1 num2 ... numn
t

Here, n denotes the number of integers in the array, followed by n space-separated integers, and finally the target integer t.

outputFormat

Output all unique combinations that sum to the target. Each valid combination should be printed on a separate line with the numbers separated by a single space. If no combination exists that meets the criteria, output nothing.

## sample
5
2 5 2 1 2
5
1 2 2

5

</p>