TopCoder problem "ContestCoordinator" used in SRM 309 (Division II Level One)



Problem Statement

    

You are the coordinator of a contest, and you have been presented with the final scores of all the contestants. It is now your job to determine the quality of the contest. To do this, you will compute the average score after eliminating the k highest scoring contestants and the k lowest scoring contestants. k is a non-negative integer (it can be 0), and you will choose a value for k that yields the maximum average score. Return a double representing this maximum average score. You are not allowed to eliminate all the scores.

 

Definition

    
Class:ContestCoordinator
Method:bestAverage
Parameters:int[]
Returns:double
Method signature:double bestAverage(int[] scores)
(be sure your method is public)
    
 

Notes

-The returned value must be accurate to 1e-9 relative or absolute.
 

Constraints

-scores will contain between 1 and 50 elements, inclusive.
-Each element of scores will be between 1 and 1000, inclusive.
 

Examples

0)
    
{1}
Returns: 1.0
There's nothing to remove here.
1)
    
{1,2,3,4}
Returns: 2.5
Eliminating the first and the last score yields an average score of 2.5
2)
    
{1,1,999,999,1000,1000}
Returns: 999.0
Keep only the scores equal to 999.
3)
    
{1,13,8,6,7,9}
Returns: 7.5
4)
    
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
Returns: 1.0

Problem url:

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

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=9989&pm=6243

Writer:

_efer_

Testers:

PabloGilberto , brett1479 , radeye , Olexiy

Problem categories:

Simple Search, Iteration