Problem Statement
We are building a rectangular house using manufactured sections for the
walls. Each section is 4 feet long. There are three types of sections: window
sections, door sections, and regular sections. We have a fixed assortment
of these sections, and want to design the house to have a maximum area, subject
to the following rules:
- 1) A house side must contain no more than one door.
- 2) The house must have at least one door.
- 3) A door section may not be at the end of a wall.
- 4) Each window section must be adjacent to two regular sections, one on each side of it in its wall.
Definition
- Class:
- HouseParty
- Method:
- maxArea
- Parameters:
- int, int, int
- Returns:
- int
- Method signature:
- int maxArea(int numReg, int numWin, int numDoor)
- (be sure your method is public)
Constraints
- numReg, numWin, and numDoor will each be between 0 and 50 inclusive.
Examples
8
0
0
Returns: 0
No house can be built since you have no door sections.8
0
1
Returns: 48
One way is to use 3 regular sections for the north wall, one regular section for the east wall and one for the west wall, and to use a door section between 2 regular sections for the south wall. This gives a house that is 12' x 4'. Below is a picture (with door and window sections shown as D and W, and regular sections shown as - or | ) --- | | -D-9
8
2
Returns: 144
One design is: -D- | | D W | | -W-6
23
13
Returns: 48
We are very short of regular sections; one design is: - | | D W | | -