#P2329. Maximum Required Boards
Maximum Required Boards
Maximum Required Boards
Farmer John wants to build a fence around his pasture and needs a set of wooden boards of specific lengths. He visits the wood store, but the owner only has some large boards available. Fortunately, John has a magical saw that can cut a board into pieces without any loss. For example, a board of length $10$ can be cut into pieces of lengths $8$ and $2$.
Given the list of required board lengths and the available board lengths from the store, determine the maximum number of required boards that can be obtained. Each available board can be cut arbitrarily into pieces, but a board piece (item) must come entirely from a single available board. In other words, you need to pack as many required pieces as possible into the available boards without exceeding their lengths.
inputFormat
The first line contains two integers n and m where n is the number of required boards and m is the number of available boards.
The second line contains n integers representing the required board lengths.
The third line contains m integers representing the lengths of the available boards.
All integers are separated by spaces.
outputFormat
Output a single integer representing the maximum number of required boards that can be obtained by cutting the available boards.
sample
4 2
7 3 5 3
10 8
4
</p>