Muz
Muz

Reputation: 759

how to minimize the bag numbers with given items?

I have 7 items called A B C D E F G, and each has its weight. The amount of A is 3, B is 2, etc, such as the following table:

enter image description here

Items will be filled in the same bag and the volume of bag is 1.0kg (the sum of volume in a bag cannot exceed 1.0kg). Now I want to use the least number of bags. How can I assign items to each bag to get the least number?

Upvotes: 0

Views: 259

Answers (1)

Stefan Mondelaers
Stefan Mondelaers

Reputation: 877

Start by putting the item with the heighest weight in bag and find additional items for the same bag (again start by trying the haviest ones first) to get a total weight as close as possible to the maximum of 1.0 kg.
Repeat the same with the remaining items until there is no item left anymore and count the bags you have used.

Upvotes: 1

Related Questions