Implementation of 1-D bin packing