#C8931. Subsets Sum Equals Target
Subsets Sum Equals Target
Subsets Sum Equals Target
Given an array of integers and a target value \(T\), find all subsets whose sum equals \(T\). Each subset must list its elements in increasing order and the overall list of subsets must be sorted in lexicographically increasing order.
If no subset exists, output a single line containing \(\[\]\).
inputFormat
The input consists of two lines:
- The first line contains two integers \(n\) and \(T\), representing the number of elements in the array and the target sum, respectively.
- The second line contains \(n\) space-separated integers representing the array elements.
outputFormat
For each subset whose sum is equal to \(T\), print a line with the subset's elements separated by a single space. The subsets must be printed in lexicographically increasing order. If no valid subset exists, print a single line containing []
.
4 7
2 3 5 7
2 5
7
</p>