MWC '15 #5 P1: Stats

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 256M

Author:
Problem types

You have just finished your edge case test in ICS. Since you are an exceptional student, your teacher has given you an extra assignment:

Find the mean, median and mode of all the test scores.

Since it's absurd to do this manually, you have burdened yourself with creating a computer program!

The mean is an average (total score divided by the number of tests). The median is the middle score, or the average of the two middle scores if there is an even number of tests. The mode is the score that occurs most often. If multiple scores occur most often, then all of them are considered modes.

Input Specification

The first line will contain a single integer N (1 \le N \le 100), the number of tests.

The second line will contain N numbers, M_n (0.0 \le M_i \le 100.0), the score that n^\text{th} person received, as a percent rounded to the nearest tenth.

Output Specification

Three lines in the following order:

  • The mean of all the test scores
  • The median of all the test scores
  • The mode(s) of all the test scores in ascending order

Output will be accepted within a margin of error of 0.1.

Sample Input

5
50 60 70 50 70

Sample Output

60
60
50 70

Explanation for Sample Output

Everyone got rekt by the edge case test, so the average was \frac{50+50+60+70+70}{5} = \frac{300}{5} = 60. The median is also 60. The modes: 50 and 70 both occurred the most with 2 times.


Comments

There are no comments at the moment.