An algorithm problem encountered in work, Is there any solution?
Anonymous User
62

Given a set of goods A, B, C, D inventory quantity And given several promotional packages of these goods (the commodity types in each package will not be repeated), what is the package combination that can consume the most commodity inventory under the condition of not exceeding the inventory of each commodity.

Example 1:
Quantity of A:1, Quantity of B:1, Quantity of C:2, Quantity of D:2
Three packages are given: [A, B, C, D], [A, C, D], [B, C, D].
Output: [A, C, D], [B, C, D]. Reason: Can consume 6 inventory items.

Example 2:
Quantity of A:2, Quantity of B:1, Quantity of C:1, Quantity of D:1
Three packages are given: [A, B, C, D], [A, C, D], [B, C, D].
Output: [A,B,C,D]. Reason: Can consume 4 inventory items.

Example 3:
Quantity of A:1, Quantity of B:0, Quantity of C:5, Quantity of D:5
Three packages are given: [A, B, C, D], [C, D], [B, C]
Output: [C, D], [C, D], [C, D], [C, D], [C, D]. Reason: Can consume 10 inventory items.

Comments (0)