Bookshelf Organizing

You have an enormous book collection and want to buy some shelves. You go to a store and they sell all kinds of shelves. The weird part is, some shelves are different in length but they all cost the same.

You now want to optimize your purchase so that you can fit as many books on the least number of shelves.

Input Example:

The first variable "shelfLength" is the available bookshelves in the store, as an int array.

The second array "books" (string array) contains book collections in the form of the book width followed by the book title.

Example 1

shelfLength : [150, 150, 300, 150, 150] 
books : {
"105AnElectricCarAnd400MKilometers" }

Example 2

shelfLength : [500, 500, 500]
books : {
"399MissionEarth" }

Output Example :

The number of bookshelves you have to buy. If you can't fit them properly, you respond with 0.

For Example 1

2 //As an integer

For Example 2

0 //As a string

Contributed by Erkan Ercan