PEG 11/12 Programming Test 1 - October 19

Problem 3: Cyclopian Cash

Alas, FurWear has failed to turn a profit from the mysterious land of Cyclopia. Upon realising that giants can wear clothing in larger sizes but not in smaller sizes, FurWear has decided to produce clothing sized according to the median of all the sizes, so as to fit approximately half the population. (Having clothing that fits the entire population would hardly make FurWear exclusive!)
Write a program to correct this silly oversight.

Input

The first line consists of a single integer N (1 ≤ N ≤ 1000), the number of Oelfinn. The following N lines each contain a single integer ai (10 ≤ ai ≤ 1000), the size of clothing worn by the ith Oelfinn.

Output

Output on a single line the median of all the sizes, to one decimal place.

Sample Input

6
28
49
18
40
69
37

Sample Output

38.5

All Submissions
Best Solutions


Point Value: 3
Time Limit: 2.00s
Memory Limit: 16M
Added: Oct 17, 2011
Author: jargon

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

Comments (Search)

The median of the numbers in sample 2 is not 38.5, meaning either they made a mistake (which I doubt) or the question is not asking for the median of i numbers. Help?

do you know what an median is? You have made an mistake, the median is the middle number in a sorted list, and if there are 2 numbers, then take the average, here, when we sort the list we get 18 28 37 40 49 69, then we take the middle 2 numbers since there are an even number of numbers, which is 37 and 40, now we take the average of the numbers, so (37 + 40)/2 = 57/2 = 38.5, which is the correct answer

can someone update the PEG judge?
my submission works in python 3.4 but I believe the PEG Judge is on version 3.2.3
I think An Admin should update the PEG judge

statistics.median is in python 3.4

Can I please see my whole error?

Traceback (most recent call last): 
File "a.out", line 2, in <module>
import statistics
ImportError: No module named statistics

statistics.median was introduced in python 3.4 , a fairly recent update the judge doesn't use