#C12028. Largest K Subset Sums
Largest K Subset Sums
Largest K Subset Sums
You are given an integer (T) denoting the number of test cases. For each test case, you are given two integers (N) and (K) followed by an array of (N) integers. Your task is to compute all possible sums of non-empty subsets of the array and then output the (K) largest distinct sums in descending order.
A subset of an array is defined as any combination of its elements (order is irrelevant). For a subset (S), its sum is given by (\sum_{x \in S} x).
For each test case, print a single line containing the (K) largest subset sums separated by a single space.
inputFormat
The first line contains a single integer (T) representing the number of test cases. For each test case:
- The first line contains two integers (N) and (K).
- The second line contains (N) space-separated integers representing the elements of the array.
outputFormat
For each test case, output one line with (K) space-separated integers representing the largest distinct subset sums in descending order.## sample
1
3 4
1 2 3
6 5 4 3