#K89272. Subsets Sum Less Than Target

    ID: 37494 Type: Default 1000ms 256MiB

Subsets Sum Less Than Target

Subsets Sum Less Than Target

Given a list of unique integers \(\{a_1, a_2, \dots, a_n\}\) and an integer \(T\), find all subsets whose sum is less than \(T\). A subset is defined as any selection of elements (possibly empty) from the list. The answer should be output in JSON format as an array of arrays. Note that the order of subsets is not important since the judging system will compare the sorted results.

Example:

Input:
2 3 6 7
7

Output: [[],[2],[3],[6],[2,3]]

</p>

inputFormat

The input is given via standard input (stdin) and consists of two lines:

  • The first line contains space‐separated unique integers.
  • The second line contains a single integer \(T\), the target.

outputFormat

The output, printed to standard output (stdout), is a JSON array of arrays. Each inner array represents a subset of the input numbers whose sum is less than \(T\). The output should be in valid JSON format.

## sample
2 3 6 7
7
[[],[2],[3],[6],[2,3]]