Tap here to switch tabs
Problem
Submissions

Problem: Building Boxes

med
30 min
Try to solve the Building Boxes problem.

Statement

You are given an integer n representing the total number of identical 1imes1imes11 imes 1 imes 1 cubic boxes you must place in the corner of a room.

A placement of boxes is valid if it satisfies the following rules:

  • Every box rests either directly on the floor or on top of another box.

  • A box can be placed on top of another box only if the supporting box is surrounded on all 44 of its vertical side faces by other boxes or room walls.

Return the minimum number of boxes that must touch the floor to place all n boxes in a valid arrangement.

Constraints:

  • 1≤1 \leq n ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Building Boxes

med
30 min
Try to solve the Building Boxes problem.

Statement

You are given an integer n representing the total number of identical 1imes1imes11 imes 1 imes 1 cubic boxes you must place in the corner of a room.

A placement of boxes is valid if it satisfies the following rules:

  • Every box rests either directly on the floor or on top of another box.

  • A box can be placed on top of another box only if the supporting box is surrounded on all 44 of its vertical side faces by other boxes or room walls.

Return the minimum number of boxes that must touch the floor to place all n boxes in a valid arrangement.

Constraints:

  • 1≤1 \leq n ≤109\leq 10^9