TopCoder problem "BadExam" used in TCHS07 Beta 1 (Division I Level One)



Problem Statement

    

A teacher has just corrected a set of exams, and the marks are terrible! He wants to make them higher, so he uses the following procedure to adjust the grades. Let mmax be the highest mark. Each mark m will be changed to m/mmax*100. For example, if the highest mark was 70 points, and you scored 50 points, your mark would become 50/70*100, which is approximately 71.43.

You will be given a int[] marks.The ith element of marks is the mark received by the ith student. Compute the new marks for the students and return the average.

 

Definition

    
Class:BadExam
Method:newAverage
Parameters:int[]
Returns:double
Method signature:double newAverage(int[] marks)
(be sure your method is public)
    
 

Notes

-The returned value must have an absolute or relative error less than 1e-9.
 

Constraints

-marks will contain between 1 and 50 elements, inclusive.
-Each element of marks will be an integer between 0 and 100, inclusive.
-At least one element of marks will be greater than zero.
 

Examples

0)
    
{40,80,60}
Returns: 75.0
The new marks are 50, 100 and 75. The average is (50 + 100 + 75) / 3 = 225 / 3 = 75.
1)
    
{10, 20, 0, 100}
Returns: 32.5
Since the maximum mark is 100, the marks are not changed.
2)
    
{50}
Returns: 100.0
3)
    
{10, 20, 30, 40, 50, 60, 70, 80, 90}
Returns: 55.55555555555556

Problem url:

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

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=10705&pm=7342

Writer:

tywok

Testers:

PabloGilberto , brett1479 , Olexiy

Problem categories:

Simple Math, Simulation