JOIN
Get Time

   Problem Statement  

 Problem Statement for BinPacking

Problem Statement

    Fox Ciel has some items. The weight of the i-th (0-based) item is item[i]. She wants to put all items into bins.



The capacity of each bin is 300. She can put an arbitrary number of items into a single bin, but the total weight of items in a bin must be less than or equal to 300.



You are given the int[] item. It is known that the weight of each item is between 100 and 300, inclusive. Return the minimal number of bins required to store all items.
 

Definition

    
Class:BinPacking
Method:minBins
Parameters:int[]
Returns:int
Method signature:int minBins(int[] item)
(be sure your method is public)
    
 

Constraints

-item will contain between 1 and 50 elements, inclusive.
-Each element of item will be between 100 and 300, inclusive.
 

Examples

0)
    
{150, 150, 150, 150, 150}
Returns: 3
You have five items and each bin can hold at most two of them. You need at least three bins.
1)
    
{130, 140, 150, 160}
Returns: 2
For example, you can distribute the items in the following way:
  • Bin 1: 130, 150
  • Bin 2: 140, 160
2)
    
{100, 100, 100, 100, 100, 100, 100, 100, 100}
Returns: 3
3)
    
{100, 200, 100, 100, 100, 100, 200, 100, 200}
Returns: 4
4)
    
{157, 142, 167, 133, 135, 157, 143, 160, 141, 123, 162, 159, 165, 137, 138, 152}
Returns: 8

This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2010, TopCoder, Inc. All rights reserved.

This problem was used for:
       Single Round Match 598 Round 1 - Division I, Level One