Statistics

Problem Statement for "BadExam"

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

  1. {40,80,60}

    Returns: 75.0

    The new marks are 50, 100 and 75. The average is (50 + 100 + 75) / 3 = 225 / 3 = 75.

  2. {10, 20, 0, 100}

    Returns: 32.5

    Since the maximum mark is 100, the marks are not changed.

  3. {50}

    Returns: 100.0

  4. {10, 20, 30, 40, 50, 60, 70, 80, 90}

    Returns: 55.55555555555556

  5. {31,32,45,12,91,43,0,55,78,21,32,43}

    Returns: 44.23076923076923

  6. {9,15,50,29,13,25,22,30,7,9,49,0,34,20,44,32,55,43,44,17,40,6,2,7,42,41,58,18,25,9,21,55,42,3,13,38,43,19,49,2,14,42,48,2,58,24,49,1,35,57}

    Returns: 48.62068965517242

  7. {87,19,14,36,81,2,80,100,89,74,71,64,87,37,80,42,68,89,96,95,99,58,57,86,4,47,54,40,46,7,27,56,62,85,99,62,75,85,17,52,26,72,13,80,65,51,35,32,57,40}

    Returns: 58.0

  8. {26,66,33,50,51,64,6,63,67,10,63,1,24,55,50,1,59,40,47,53,45,15,45,19,24,1,35,38,47,20,21,51,35,26,39,29,7,58,25,35,22,64,55,61,20,19,67,65,3,8}

    Returns: 54.56716417910448

  9. {57,19,15,4,24,35,31,8,33,20,27,39,25,29,16,38,9,62,4,53,11,7,26,53,38,32,64,39,40,46,46,62,3,22,8,32,43,12,58,61,48,37,39,0,21,39,19,22,7,29}

    Returns: 47.25

  10. {19,38,18,62,7,48,64,31,52,8,26,34,10,62,10,8,43,22,24,45,61,22,51,24,0,48,31,38,52,18,4,30,48,18,29,21,42,58,64,29,3,13,0,24,58,59,59,38,23,37}

    Returns: 51.03125

  11. {65,10,67,8,16,9,44,9,22,37,53,15,51,11,53,54,25,60,43,51,67,7,13,9,11,40,20,18,27,35,70,49,47,65,3,35,59,22,55,27,49,13,2,63,23,44,69,70,48,20}

    Returns: 50.94285714285713

  12. {44,23,36,7,3,7,1,21,0,46,30,11,48,28,48,15,44,27,15,47,21,32,48,20,46,43,50,23,50,17,16,3,10,18,2,29,15,10,23,43,28,38,42,30,6,8,49,38,15,10}

    Returns: 51.36

  13. {32,40,3,23,73,1,55,64,48,30,58,53,62,9,17,9,48,58,58,3,35,11,41,37,47,54,13,66,66,23,50,13,39,44,43,3,0,38,40,54,12,70,56,51,70,35,38,15,25,66}

    Returns: 52.02739726027397

  14. {31,73,47,90,75,41,3,49,19,98,76,13,82,57,55,51,59,29,2,44,55,22,53,26,58,6,5,36,100,45,92,81,67,23,79,8,15,73,73,67,66,26,76,7,74,19,42,67,5,38}

    Returns: 47.96

  15. {29,28,0,12,34,12,16,30,44,23,2,42,27,18,10,22,37,44,6,1,33,39,23,29,12,48,38,44,7,18,29,10,25,25,52,49,47,44,40,12,4,32,32,35,44,43,14,32,8,2}

    Returns: 50.269230769230774

  16. {24,23,36,19,17,13,29,44,18,35,0,54,51,3,2,43,33,1,6,49,53,1,7,53,32,47,40,18,11,9,15,23,13,42,3,12,25,48,17,56,41,0,51,5,38,49,2,31,46,30}

    Returns: 47.07142857142857

  17. {50,100,27,14,64,16,93,21,63,22,58,21,30,26,38,31,7,99,100,56,3,37,37,38,62,36,44,51,41,67,0,73,59,72,78,88,71,78,37,53,74,11,21,67,49,4,30,18,81,49}

    Returns: 47.3

  18. {72,33,61,39,93,52,98,20,69,35,88,42,50,82,50,83,83,28,8,97,51,1,54,26,59,21,73,58,15,3,48,63,15,100,100,54,2,51,35,47,36,19,41,30,34,71,58,98,80,54}

    Returns: 51.6

  19. {32,54,40,38,59,52,36,47,15,45,17,12,41,22,29,29,31,48,4,6,50,10,58,30,50,36,23,47,1,55,12,4,35,52,2,16,41,45,38,48,7,39,34,32,53,59,24,14,5,11}

    Returns: 53.83050847457627

  20. {96,90,62,56,2,57,4,26,17,3,97,36,49,58,46,95,43,63,5,49,74,57,63,49,81,35,26,50,37,79,15,13,70,26,93,13,3,9,89,19,52,40,61,54,7,52,26,47,33,80}

    Returns: 47.567010309278366

  21. {9,9,35,23,43,41,29,33,1,34,20,48,2,25,14,45,2,7,25,12,26,30,1,24,26,46,37,29,50,33,38,30,34,7,40,32,36,11,42,2,45,11,9,27,16,7,17,37,49,2}

    Returns: 50.04

  22. {30,39,56,38,18,33,47,24,20,61,36,40,59,9,37,1,7,27,6,29,24,17,5,60,55,39,5,6,37,15,25,37,57,57,49,58,15,9,44,39,18,20,15,36,38,15,33,38,28,51}

    Returns: 51.21311475409834

  23. {12,24,4,3,44,27,43,8,30,29,55,16,9,22,18,28,33,50,66,58,1,59,21,8,54,49,30,41,20,7,64,41,28,32,26,39,44,59,52,51,22,23,5,10,29,24,44,45,11,17}

    Returns: 46.51515151515152

  24. {12,9,32,4,56,51,60,61,28,37,21,55,59,30,45,49,59,32,20,12,34,36,31,5,41,43,51,22,46,18,46,42,16,1,15,22,29,44,8,57,49,8,44,18,36,41,55,0,5,43}

    Returns: 53.70491803278688

  25. {24,71,41,51,57,21,23,12,43,13,37,2,4,44,76,25,22,75,26,54,3,46,35,70,11,30,76,43,29,59,10,45,24,27,32,6,12,38,18,65,3,20,6,0,33,48,1,40,62,38}

    Returns: 43.44736842105263

  26. {51,92,61,36,58,64,72,16,19,38,18,54,34,85,33,26,20,20,82,29,81,39,2,71,3,55,61,88,25,26,15,36,1,38,32,64,80,70,85,85,36,20,14,37,37,91,87,53,8,18}

    Returns: 49.260869565217405

  27. {64,67,38,63,77,0,5,83,78,25,23,12,46,65,5,2,61,10,75,7,25,64,11,22,62,62,81,71,70,27,15,65,70,43,11,68,64,37,71,68,5,72,5,13,31,80,28,36,26,50}

    Returns: 52.02409638554218

  28. {21,44,85,70,88,20,83,77,79,22,31,85,9,47,31,55,73,61,13,42,56,56,34,73,87,74,7,49,47,67,76,47,62,31,55,61,84,91,57,50,17,98,90,99,8,69,86,59,8,15}

    Returns: 55.53535353535352

  29. {40,11,44,30,25,37,31,23,13,11,30,21,40,23,10,2,4,0,29,39,4,11,46,15,20,0,41,36,6,21,9,9,50,39,44,0,51,12,47,22,2,29,23,41,42,17,7,13,4,41}

    Returns: 45.686274509803944

  30. {8,46,11,32,18,11,30,0,41,41,26,6,8,8,5,1,49,31,5,47,10,17,7,9,33,1,35,40,37,10,28,24,18,27,12,23,50,19,35,40,5,46,26,32,24,36,38,25,14,35}

    Returns: 47.2

  31. {64,10,51,8,9,14,61,34,20,68,40,25,74,45,34,34,51,8,28,25,42,18,15,61,23,64,32,64,47,35,32,43,43,35,19,32,65,39,49,6,31,27,17,35,69,75,5,41,14,24}

    Returns: 48.13333333333332

  32. {34,8,5,24,40,47,26,8,45,44,31,34,11,54,8,25,20,21,20,35,10,37,24,20,15,4,56,53,29,41,29,17,43,27,36,53,11,16,5,42,1,56,26,22,24,17,30,47,21,0}

    Returns: 48.28571428571428

  33. {94,42,87,5,9,46,99,88,87,53,20,51,9,34,37,37,50,43,37,48,29,18,10,82,25,11,83,22,83,79,76,33,23,98,41,40,14,17,95,18,9,3,63,40,50,92,13,41,60,50}

    Returns: 46.34343434343434

  34. {36,29,41,51,46,12,22,24,35,35,45,19,27,47,48,8,43,44,0,44,37,17,14,12,4,22,39,7,34,38,35,33,49,12,46,43,21,38,45,25,46,46,35,7,27,37,53,36,39,34}

    Returns: 59.88679245283019

  35. {42,58,71,34,35,69,49,42,66,17,31,33,48,57,6,21,49,38,86,72,80,41,8,81,71,89,57,15,42,43,24,3,73,19,47,35,53,89,28,86,76,49,83,50,91,36,39,85,73,13}

    Returns: 55.010989010989015

  36. {100,1};

    Returns: 50.5

  37. {1,1,1,1,1,1,1,1,1,1}

    Returns: 100.0

  38. {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}

    Returns: 5.882352941176471

  39. {31,31,31,31,0,31,90}

    Returns: 38.88888888888889

  40. {77, 78 }

    Returns: 99.35897435897436

  41. {77, 78 }

    Returns: 99.35897435897436


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: