TopCoder problem "ColorfulRabbits" used in SRM 499 (Division I Level One , Division II Level Two)



Problem Statement

    Cat Pochi visited a town of rabbits and asked some of the rabbits the following question: "How many rabbits in this town other than yourself have the same color as you?". The rabbits all replied truthfully, and no rabbit was asked the question more than once. You are given the rabbits' replies in the int[] replies. Return the minimum possible number of rabbits in this town.
 

Definition

    
Class:ColorfulRabbits
Method:getMinimum
Parameters:int[]
Returns:int
Method signature:int getMinimum(int[] replies)
(be sure your method is public)
    
 

Constraints

-replies will contain between 1 and 50 elements, inclusive.
-Each element of replies will be between 0 and 1,000,000, inclusive.
 

Examples

0)
    
{ 1, 1, 2, 2 }
Returns: 5
If there are 2 rabbits with a color and 3 rabbits with another color, Pochi can get this set of replies.



1)
    
{ 0 }
Returns: 1
A poor lonely rabbit.
2)
    
{ 2, 2, 44, 2, 2, 2, 444, 2, 2 }
Returns: 499

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=11327

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=14428&pm=11327

Writer:

lyrically

Testers:

PabloGilberto , ivan_metelsky , nika

Problem categories:

Simple Math