Statistics

Problem Statement for "Fuses"

Problem Statement

Homes typically have 20 amp fuses in their fuseboxes. Appliances are then hooked up to the fuses. If the appliances connected to a single fuse ever draw more than 20 amps, the fuse will blow (which you would like to avoid). In large homes with a large number of appliances, multiple 20 amp fuses may be required to accommodate all of the appliances. You have a number of large appliances, each of which must be connected to some fuse. The number of amps used by each appliance will be given by amps. Your task is to find the minimum number of 20 amp fuses that can accommodate all of the appliances.

Definition

Class:
Fuses
Method:
minFuses
Parameters:
int[]
Returns:
int
Method signature:
int minFuses(int[] amps)
(be sure your method is public)

Constraints

  • Each element of amps will be between 1 and 10, inclusive.
  • amps will contain between 1 and 10 elements, inclusive.

Examples

  1. {10,10}

    Returns: 1

    We can hook up two 10 amp appliances to one 20 amp fuse.

  2. {10,10,10,10,10,10,10,10,10,10}

    Returns: 5

    Here we require five 20 amp fuses. We hook up two appliances to each one.

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

    Returns: 3

  4. {9,9,8,3,5,6}

    Returns: 2

  5. {4,4,8,9,9,10}

    Returns: 3

  6. {10,8,10,5,5,8}

    Returns: 3

  7. {9,10,7,10,10,2,4,10}

    Returns: 4

  8. {6,10,7,10,10,10}

    Returns: 3

  9. {10,8,5,10,8,7}

    Returns: 3

  10. {8,10,9,8,5,10,10,10,10,10}

    Returns: 5

  11. {10,2,9,10,7,10,9,10,9,9}

    Returns: 5

  12. {10,6,10,10,9,10,5,1,9}

    Returns: 4

  13. {8,4,10}

    Returns: 2

  14. {9,5,9,10,10,9,4,9,10}

    Returns: 4

  15. {9,9,6,6,5,9,10,10}

    Returns: 4

  16. {10,5,9,10,10,6,9,8,10}

    Returns: 4

  17. {9,6,10,5}

    Returns: 2

  18. {10,9,6,10,8,3,9,5}

    Returns: 3

  19. {9,8,10,10}

    Returns: 2

  20. {10,10,8,10,4,10,9}

    Returns: 4

  21. {6,10,10,9,10,8,4,10,8,8}

    Returns: 5

  22. {9,9,7,9,7,10,7,6}

    Returns: 4

  23. {6,7,8,8,4,7}

    Returns: 2

  24. {6,6,10,8,8,5,9,10,1,10}

    Returns: 4

  25. {10,5,3,10,8,8,10}

    Returns: 3

  26. {9,8,10,4,2,10,10,9,8}

    Returns: 4

  27. {10,6,8,9}

    Returns: 2

  28. {5,8,10,10}

    Returns: 2

  29. {5,8,10,9,10,8,7}

    Returns: 3

  30. {9,10,10,10,3,9,10,10,9,4}

    Returns: 5

  31. {10,10,10,6,10,9}

    Returns: 3

  32. {9,6,8,10,10,10,10,2,10,10}

    Returns: 5

  33. {10,5,10,7,9,10,10}

    Returns: 4

  34. {10,5,10}

    Returns: 2

  35. {10,4,6,10,5,6,5,10,8,10}

    Returns: 4

  36. {10,2,9,8,8,10,10,6,5,10}

    Returns: 4

  37. {10,9,9,7,9,9,5,9,10,6}

    Returns: 5

  38. {10,7,10,7,10,10,8,9,8,10}

    Returns: 5

  39. {8,4,7,9,10,6,10,9,10,10}

    Returns: 5

  40. {3,5,8,6,2,10}

    Returns: 2

  41. {10,10,10,8,10,3,10,7,10,10}

    Returns: 5

  42. {10,10,10,10,8,7,9,10,7,10}

    Returns: 5

  43. {10,10,10,8,5,10,7,10,10}

    Returns: 4

  44. {10,8,10,10,2,3}

    Returns: 3

  45. {9,10,4,10,6,8,3,9,10,8}

    Returns: 4

  46. {10,9,10,9,10,10,10,10,8,10}

    Returns: 5

  47. {8,10,10,3,3,7,10,8,10}

    Returns: 4

  48. {10,9,10,10,9,9,8,6,10}

    Returns: 5

  49. {10,10,9,10,10,9,9,8,8,10}

    Returns: 5

  50. {10,6,5,7,5,6,9,9,9,8}

    Returns: 4

  51. {9,2,7}

    Returns: 1

  52. {10,4,7,2,10,7,10,10,7,9}

    Returns: 4

  53. {5,9,7,2,7}

    Returns: 2

  54. {7,9,7,10,10,5,3,9,8,3}

    Returns: 4

  55. {8,10,9,10,5,5,7,9,9,8}

    Returns: 5

  56. {8,8,8,8,8,8,8,8,8,8}

    Returns: 5

  57. {9,9,9,9,9,9,9,9,9,9}

    Returns: 5

  58. {9,9,9,9,9,9,9,9,9}

    Returns: 5

  59. {8,8,8,8,8,8,8,8,8}

    Returns: 5

  60. {7,7,7,7,7,7,7,7,7,7}

    Returns: 5

  61. {7,7,7,7,7,7,7,7,7}

    Returns: 5

  62. {6,6,6,6,6,6,6,6,6,6}

    Returns: 4

  63. {6,6,6,6,6,6,6,6,6,7}

    Returns: 4

  64. {7,7,6,7,7,5,7,7,7}

    Returns: 4


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: