Lab 3.2: Knapsack problem

Lab 3.2: Knapsack problem

You cannot submit for this problem because the homework's deadline is due.

Description

Use python3 or OCmal to implement the correct solution of Knapsack problem (Subset sum problem).
The set only contains positive numbers, and the solution for the problem is unique. Therefore, you do not need to consider multiple solutions when you are trying to solve this problem.

Submission Format

Submit a tar or zip file including a script named knapsack.py or knapsack.ml.

IO

Input

The first line contains the sum S.
The second line contains the set of numbers, separated by single space.

Output

If there is a subset summing up to S, output the subset in sorted order.
If there is not, output nothing.

Sample IO

Sample 1

input

4
1 2 5

output

There is nothing in this output, even without any space or line breaks.


Sample 2

input

0
1 3 4 5

output

An empty set have a sum equals to 0.

[]

Sample 3

input

7
1 3 4 5

output

[3, 4]

Lab 3

Not Claimed
Status
Finished
Problems
4
Open Since
2022-10-13 00:00
DDL
2022-11-03 23:59
Extension
72.0 hour(s)