Packing Balls 2
Time limit2sMemory limit512 MB
Given counts of balls in K colors, pack them into boxes of capacity K where each box is all one color or all distinct colors, using as few boxes as possible.
Problem
The balls come in colors. A color is an integer from 1 to , and there are balls of color .
You want to pack all of the balls into boxes. One box holds at most balls.
The balls inside one box must all have different colors, or must all have the same color.
Write a program that finds the minimum number of boxes you need.
Input
The first line contains the number of colors . ()
The second line contains , the ball counts of color 1 through color , separated by spaces. ()
Output
Print the minimum number of boxes on the first line.