There is a rectangular hole in the ground.
You are given the dimensions of this rectangle: ints holeH and holeW.
You have a collection of rectangular boards.
You are given their dimensions as two ints: boardH and boardW.
For each valid i, you have a rectangular board with dimensions boardH[i] and boardW[i].
You would like to cover the hole completely, using as few of these boards as possible.
There are some rules you must follow when covering the hole:
- The boards may overlap arbitrarily.
- Together, the boards must cover the entire hole.
- You may rotate each board, but you must place it so that the sides of the board are parallel to the sides of the hole.
- All corners of each board must be strictly outside the hole. (That is, they are not allowed to lie on the boundary of the hole, either.)
If you can cover the hole using the boards you have, return the smallest number of boards that is sufficient to cover the hole. Otherwise, return -1.
|Parameters:||int, int, int, int|
|Method signature:||int minimumNumber(int holeH, int holeW, int boardH, int boardW)|
|(be sure your method is public)|
|-||holeH and holeW will be between 1 and 1,000,000,000, inclusive.|
|-||boardH and boardW will contain between 1 and 50 elements, inclusive.|
|-||boardH and boardW will contain the same number of elements.|
|-||Each element of boardH and boardW will be between 1 and 1,000,000,000, inclusive.|
|You cannot cover this hole completely by using a single board. You can cover it by taking any two boards and placing them side by side.|
|These four boards cannot be used to cover the hole. This is because of the rule that all board corners must be outside the hole.|
|The corners of a board are not allowed to be on the boundary of the hole.|
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.