Statistics

Problem Statement for "SixteenBricks"

Problem Statement

You have 16 bricks. Each brick has the shape of a rectangular box. You are given a int[] height. For each i, one of your bricks has dimensions 1 x 1 x height[i].


You also have an opaque table. You are going to place your 16 bricks onto the table in a specific way. You are not allowed to rotate the bricks while placing them: the dimension given in height must always be vertical. On the table, there is a 4 x 4 grid of squares. You have to place exactly one of your bricks onto each of the squares.


After you place all the bricks, we will look at the solid formed by them. We are interested in the visible surface area of the solid. Note that the bottom sides of your bricks are not a part of the visible surface, as they stand on the table. Also, adjacent bricks always touch each other and the parts where they touch are not visible.


Different arrangements of bricks may lead to different visible surfaces. Return the largest possible visible surface area.

Definition

Class:
SixteenBricks
Method:
maximumSurface
Parameters:
int[]
Returns:
int
Method signature:
int maximumSurface(int[] height)
(be sure your method is public)

Constraints

  • height will contain exactly 16 elements.
  • Each element of height will be between 1 and 100, inclusive.

Examples

  1. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}

    Returns: 32

    All your bricks look the same. The only solid you can construct is a 1 x 4 x 4 box. The bottom side of the box is not visible, the other five sides are. The total visible surface area is 4*4 + 4*(1*4) = 32.

  2. {1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2}

    Returns: 64

    In order to maximize the visible surface area, you should produce a configuration in which no two bricks with height 2 share a common face.

  3. {77, 78, 58, 34, 30, 20, 8, 71, 37, 74, 21, 45, 39, 16, 4, 59}

    Returns: 1798

  4. {28,70,37,74,88,6,81,96,71,87,61,17,28,66,56,82}

    Returns: 2222

  5. {86,96,83,58,8,5,85,5,20,16,26,92,13,14,28,14}

    Returns: 2094

  6. {57,72,55,82,38,60,45,91,31,54,24,71,96,88,89,95}

    Returns: 2148

  7. {27,26,26,27,27,27,28,29,27,28,29,27,28,29,27,26}

    Returns: 494

  8. {51,21,16,36,38,55,16,54,72,14,65,73,30,82,30,52}

    Returns: 1718

  9. {84,33,70,49,62,58,77,72,6,48,23,41,10,67,25,47}

    Returns: 1864

  10. {93,56,90,22,60,67,77,93,20,12,11,22,69,36,83,79}

    Returns: 2328

  11. {97,97,98,98,98,98,97,98,98,98,98,98,97,98,97,97}

    Returns: 1600

  12. {13,38,35,24,6,7,45,2,3,2,43,22,37,25,2,24}

    Returns: 1048

  13. {33,98,70,31,79,24,92,52,75,72,36,43,74,78,23,90}

    Returns: 2174

  14. {4,3,3,3,4,3,4,4,3,4,4,4,3,3,3,4}

    Returns: 96

  15. {8,8,5,5,6,8,2,5,6,8,4,6,3,4,7,8}

    Returns: 196

  16. {83,92,81,73,76,94,61,63,60,63,89,58,91,76,59,62}

    Returns: 1784

  17. {38,9,22,26,65,46,35,58,64,46,29,25,17,68,36,66}

    Returns: 1512

  18. {4,8,4,11,5,3,2,7,12,3,10,3,7,2,7,12}

    Returns: 270

  19. {36,8,67,36,25,78,95,62,29,18,80,7,25,12,69,70}

    Returns: 2024

  20. {20,80,26,11,5,33,13,87,51,33,73,70,51,56,77,37}

    Returns: 1948

  21. {43,13,8,11,57,62,13,26,18,12,51,25,54,50,47,32}

    Returns: 1412

  22. {40,42,41,29,50,23,40,41,41,65,46,64,61,69,37,11}

    Returns: 1340

  23. {76,76,49,49,56,7,2,71,89,83,46,57,70,90,82,92}

    Returns: 2216

  24. {85,82,66,67,56,81,60,57,55,65,60,55,79,62,60,60}

    Returns: 1458

  25. {61,46,98,37,85,59,97,87,77,68,86,71,34,92,26,26}

    Returns: 2228

  26. {6,25,74,59,62,38,20,42,6,59,20,38,65,47,69,17}

    Returns: 1712

  27. {47,42,19,45,90,87,73,96,11,15,33,95,66,58,64,49}

    Returns: 2150

  28. {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}

    Returns: 32

  29. {21,36,61,82,73,21,81,23,30,78,5,35,83,20,35,45}

    Returns: 1882

  30. {15,7,17,39,28,18,36,30,15,3,11,8,36,7,33,17}

    Returns: 842

  31. {81,31,45,23,87,47,80,59,36,34,29,47,68,62,38,28}

    Returns: 1676

  32. {56,55,51,42,31,53,84,43,38,82,74,89,69,57,47,77}

    Returns: 1726

  33. {81,50,27,90,70,67,75,40,44,85,80,83,67,44,80,62}

    Returns: 1924

  34. {2,1,2,1,2,1,1,2,2,1,1,2,2,1,2,2}

    Returns: 64

  35. {69,42,77,39,30,43,62,42,34,70,72,72,42,51,71,66}

    Returns: 1666

  36. {25,32,17,44,45,50,11,66,38,12,49,42,15,62,40,24}

    Returns: 1354

  37. {5,7,26,8,9,23,27,24,26,10,12,26,26,4,8,26}

    Returns: 732

  38. {16,22,14,20,18,15,22,19,14,11,21,9,19,14,22,9}

    Returns: 490

  39. {3,8,2,8,2,2,6,5,4,2,9,5,3,7,5,7}

    Returns: 200

  40. {97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97}

    Returns: 1568

  41. {99,93,75,80,93,84,95,86,94,76,99,77,82,78,92,85}

    Returns: 1782

  42. {79,43,17,44,56,67,53,22,21,83,86,17,36,64,39,33}

    Returns: 1784

  43. {90,90,92,92,95,94,96,98,99,87,88,94,90,96,86,90}

    Returns: 1664

  44. {59,95,94,21,43,25,23,79,87,82,48,40,40,76,26,22}

    Returns: 2096

  45. {92,89,69,88,70,71,97,87,66,92,96,97,75,86,97,99}

    Returns: 1908

  46. {71,79,69,82,63,74,76,63,71,64,60,72,76,71,67,75}

    Returns: 1418

  47. {30,87,95,21,72,86,31,69,60,92,66,56,51,60,9,96}

    Returns: 2212

  48. {57,42,62,2,20,85,78,92,53,73,29,87,92,61,36,16}

    Returns: 2210

  49. {96,91,87,75,62,60,53,75,99,90,98,66,49,72,74,77}

    Returns: 1940

  50. {16,56,68,41,37,45,90,33,68,15,13,31,94,88,21,86}

    Returns: 2082

  51. {97,97,96,94,88,95,89,95,89,91,89,90,89,91,94,92}

    Returns: 1634

  52. {51,30,47,47,33,39,1,13,63,78,16,48,6,30,55,41}

    Returns: 1530

  53. {100,99,100,100,100,100,100,100,99,100,100,100,99,100,99,99}

    Returns: 1630

  54. {23,67,54,64,71,47,83,29,42,50,68,67,61,62,76,25}

    Returns: 1720

  55. {78,23,65,42,34,77,66,52,89,97,35,35,73,55,68,97}

    Returns: 2040

  56. {100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100}

    Returns: 1616

  57. {100,1,100,1,100,1,1,100,1,100,1,100,1,100,100,1}

    Returns: 3200

  58. {77, 78, 58, 34, 30, 20, 8, 71, 37, 74, 21, 45, 39, 16, 4, 59 }

    Returns: 1798

  59. {100, 100, 100, 100, 100, 100, 100, 100, 50, 50, 49, 49, 49, 49, 48, 48 }

    Returns: 2440

  60. {59, 39, 67, 46, 29, 89, 90, 48, 71, 52, 19, 26, 86, 12, 82, 98 }

    Returns: 2180

  61. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }

    Returns: 32

  62. {1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2 }

    Returns: 64

  63. {32, 67, 12, 56, 98, 34, 78, 100, 1, 4, 79, 24, 59, 60, 61, 62 }

    Returns: 2212

  64. {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }

    Returns: 368

  65. {1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2 }

    Returns: 64

  66. {25, 88, 87, 84, 25, 41, 98, 48, 55, 89, 92, 10, 93, 19, 44, 34 }

    Returns: 2394

  67. {16, 15, 12, 8, 14, 13, 9, 4, 11, 10, 6, 2, 7, 5, 3, 1 }

    Returns: 368

  68. {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 15, 16 }

    Returns: 212

  69. {1, 2, 5, 10, 13, 22, 17, 6, 100, 99, 70, 40, 60, 81, 37, 88 }

    Returns: 2236


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: