Background
Bin packing, or the placement of objects of certain weights into different bins subject to certain constraints, is an historically interesting problem. Some bin packing problems are NP-complete but are amenable to dynamic programming solutions or to approximately optimal heuristic solutions.In this problem you will be solving a bin packing problem that deals with recycling glass.
The Problem
Recycling glass requires that the glass be separated by color into one of three categories: brown glass, green glass, and clear glass. In this problem you will be given three recycling bins, each containing a specified number of brown, green and clear bottles. In order to be recycled, the bottles will need to be moved so that each bin contains bottles of only one color.The problem is to minimize the number of bottles that are moved. You may assume that the only problem is to minimize the number of movements between boxes.
For the purposes of this problem, each bin has infinite capacity and the only constraint is moving the bottles so that each bin contains bottles of a single color. The total number of bottles will never exceed 2^31.
在回收玻璃瓶時我們根據其顏色分為三類:棕色、綠色、和透明三種。在問題當中會 有三個回收桶,裡面含有若干個上述三種顏色的瓶子。為了要能徹底做好回收,我們 必須要將一些瓶子從某個回收桶拿出放到另外一個,使得到最後每個桶子裡都只有一 種顏色的瓶子。
我們現在所要做的就只有一個目的,讓移動瓶子的步數盡可能地弄到最少。
我們可以假設這些回收桶都具有無限的容量,所以我們唯一要關心的就只有 如何操作,讓每個桶子裡都只含有一種顏色的瓶子。瓶子的總數量不會超過 2 的 31 次方。