Statistics

Problem Statement for "ShipBoxes"

Problem Statement

Find the least-cost 3D box that can hold two given 3D boxes. The boxes must be kept orthogonal (not tilted) although they can be rotated at any multiple of 90 degrees in 3-space. Cost is the total area of cardboard required for the enclosing box, where four sides have one layer of cardboard and two ends have two layers of cardboard. The two boxes that are enclosed may not overlap (consider them already filled). You are given the dimensions of the two boxes as int[]s, where each int[] contains exactly three elements.

Definition

Class:
ShipBoxes
Method:
bestCost
Parameters:
int[], int[]
Returns:
int
Method signature:
int bestCost(int[] box1, int[] box2)
(be sure your method is public)

Constraints

  • box1 and box2 must each contain exactly 3 elements.
  • Each element of box1 and box2 will be between 1 and 10,000, inclusive.

Examples

  1. {1,4,9}

    {1,4,9}

    Returns: 140

    These two boxes have the shape of the monolith from 2001, A Space Odyssey---mostly flat. The most economical way to ship them is to stack them on top of each other and put the flaps at the small ends. The top of the box then is 4x9, the sides are 2x9, and the ends are 2x4; the total area of cardboard required is thus 140.

  2. {10000,10000,10000}

    {10000,10000,10000}

    Returns: 1200000000

  3. {314,159,262}

    {271,818,282}

    Returns: 1483466

  4. {1,1,1}

    {1,1,1}

    Returns: 12

  5. {1,9000,9000}

    {40,40,40}

    Returns: 164214000

  6. {9627,9344,3773}

    {5652,5696,5646}

    Returns: 669089316

  7. {3285,9049,7352}

    {1391,3122,6053}

    Returns: 318705840

  8. {1857,3875,5935}

    {5651,3546,7847}

    Returns: 282384980

  9. {595,3423,3181}

    {3779,1834,9227}

    Returns: 151279196

  10. {4924,9230,904}

    {5355,9133,1219}

    Returns: 183518540

  11. {5367,4548,548}

    {5503,1254,14}

    Returns: 66464564

  12. {4086,1440,3451}

    {6510,9955,5144}

    Returns: 399544420

  13. {4817,1091,7468}

    {5355,2401,9625}

    Returns: 245103390

  14. {2316,5275,1301}

    {4423,5514,3712}

    Returns: 187491120

  15. {5929,4836,7469}

    {2525,2418,5740}

    Returns: 327557686

  16. {6570,6076,5880}

    {7595,3,1835}

    Returns: 324635290


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)2024, TopCoder, Inc. All rights reserved.
This problem was used for: