TopcoderArchiveVisit Topcoder
SRM28 Jun 2006
SRM 309

ContestCoordinator

Problem statement, definition, constraints, and public examples.

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

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