Statistics

Problem Statement for "MutaliskEasy"

Problem Statement

Fox Ciel is writing an AI for the game Starcraft and she needs your help.

In Starcraft, one of the available units is a mutalisk. Mutalisks are very useful for harassing Terran bases. Fox Ciel has one mutalisk. The enemy base contains one or more Space Construction Vehicles (SCVs). Each SCV has some amount of hit points.

When the mutalisk attacks, it can target up to three different SCVs.
  1. The first targeted SCV will lose 9 hit points.
  2. The second targeted SCV (if any) will lose 3 hit points.
  3. The third targeted SCV (if any) will lose 1 hit point.
If the hit points of a SCV drop to 0 or lower, the SCV is destroyed. Note that you may not target the same SCV twice in the same attack.

You are given a int[] HP containing the current hit points of your enemy's SCVs. Return the smallest number of attacks in which you can destroy all these SCVs.

Definition

Class:
MutaliskEasy
Method:
minimalAttacks
Parameters:
int[]
Returns:
int
Method signature:
int minimalAttacks(int[] x)
(be sure your method is public)

Constraints

  • x will contain between 1 and 3 elements, inclusive.
  • Each element in x will be between 1 and 60, inclusive.

Examples

  1. {12,10,4}

    Returns: 2

    You can destroy all SCVs in two attacks as follows: Target the SCVs in the order 0, 2, 1. Their hit points after the attack will be {12-9, 10-1, 4-3} = {3, 9, 1}. Target the SCVs in the order 1, 0, 2. Their hit points will drop exactly to {0, 0, 0}.

  2. {54,18,6}

    Returns: 6

    You should attack 6 times, always in the order 0, 1, 2.

  3. {55,60,53}

    Returns: 13

  4. {1,1,1}

    Returns: 1

  5. {60, 40}

    Returns: 9

  6. {60}

    Returns: 7

  7. {1}

    Returns: 1

  8. {60}

    Returns: 7

  9. {51}

    Returns: 6

  10. {16,57,52}

    Returns: 10

  11. {55}

    Returns: 7

  12. {52,49,38}

    Returns: 11

  13. {3,22}

    Returns: 3

  14. {25,33,56}

    Returns: 9

  15. {14}

    Returns: 2

  16. {1,40,24}

    Returns: 6

  17. {15,13}

    Returns: 3

  18. {45,53}

    Returns: 9

  19. {22}

    Returns: 3

  20. {43,32}

    Returns: 7

  21. {37,26}

    Returns: 6

  22. {9}

    Returns: 1

  23. {18,46,9}

    Returns: 6

  24. {27,17}

    Returns: 4

  25. {31,45,27}

    Returns: 9

  26. {50,8}

    Returns: 6

  27. {38,49}

    Returns: 8

  28. {9}

    Returns: 1

  29. {37,31}

    Returns: 7

  30. {33}

    Returns: 4

  31. {28}

    Returns: 4

  32. {29,9,47}

    Returns: 7

  33. {1}

    Returns: 1

  34. {38}

    Returns: 5

  35. {34}

    Returns: 4

  36. {28,20,55}

    Returns: 8

  37. {59,8}

    Returns: 7

  38. {37,52,49}

    Returns: 11

  39. {37}

    Returns: 5

  40. {20}

    Returns: 3

  41. {46,57}

    Returns: 9

  42. {26,7}

    Returns: 3

  43. {27,47,4}

    Returns: 7

  44. {23,8,13}

    Returns: 4

  45. {14,50,15}

    Returns: 7

  46. {59,11}

    Returns: 7

  47. {2,33}

    Returns: 4

  48. {55,7,48}

    Returns: 9

  49. {58,26}

    Returns: 8

  50. {57,20,12}

    Returns: 7

  51. {7}

    Returns: 1

  52. {20,26,27}

    Returns: 6

  53. {34}

    Returns: 4

  54. {29,55,19}

    Returns: 9

  55. {37}

    Returns: 5

  56. {42,49,3}

    Returns: 8

  57. {14}

    Returns: 2

  58. {9, 15 }

    Returns: 3

  59. {60, 60, 60 }

    Returns: 14

  60. {9, 9, 8 }

    Returns: 3

  61. {12, 10, 4 }

    Returns: 2

  62. {60, 53, 51 }

    Returns: 13

  63. {10, 1, 1 }

    Returns: 2

  64. {1, 1, 60 }

    Returns: 7

  65. {60, 1, 1 }

    Returns: 7

  66. {14, 16, 22 }

    Returns: 4

  67. {10 }

    Returns: 2

  68. {12, 9, 5 }

    Returns: 3

  69. {8, 8, 8 }

    Returns: 3

  70. {7, 3, 2 }

    Returns: 2

  71. {10, 1 }

    Returns: 2

  72. {28, 1, 1 }

    Returns: 4

  73. {60, 13, 17 }

    Returns: 8

  74. {60, 57, 59 }

    Returns: 14

  75. {9 }

    Returns: 1

  76. {18, 7, 1 }

    Returns: 3

  77. {1, 3, 9 }

    Returns: 1

  78. {6, 9, 9 }

    Returns: 2

  79. {60, 10, 1 }

    Returns: 7

  80. {52 }

    Returns: 6

  81. {27, 8, 4 }

    Returns: 4

  82. {18, 18, 3 }

    Returns: 4

  83. {1, 9, 3 }

    Returns: 1

  84. {5, 15, 19 }

    Returns: 3

  85. {8, 3, 2 }

    Returns: 2

  86. {6, 6, 1 }

    Returns: 2

  87. {54, 1, 1 }

    Returns: 6

  88. {10, 2 }

    Returns: 2


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: