Can someone help me solve this question

You are given an infinite area with two intersecting walls ( function as X ,Y and Z axis). You are given a number N. You have to place N cubes of 1x1x1 dimensions. There are rules for placing cubes, they are as follows:

**Rules:
1.You can place a cube on another cube,only if the cube is covered on 4 sides by cubes.
2.The cube may also covered by having wall on 1 or 2 sides and cubes on other sides, you can place cubes on such cubes.
**

Minimize the area taken to place all the N cubes.

example:
N= 4;
area = 3;
explaination:
1st cube is placed at the intersection of walls suc that, the walls cover 2 of its 4 sides.
2 and 3rd cube are placed at the two reamining sides of the first cube.
4th cube is placed on 1st cube(as 1st cube is covered on 4 sides.

Comments (1)