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)

I keep trying edge cases, but never seem to get it wrong?
can someone just check my code over?
Thanks in advance :-)

Read the output format carefully.

In general, it's a good idea to take a very thorough look at the problem statement.

what's wrong?

instead of just saying "whats wrong", please give some context or other things on what is wrong with your program (i.e indexoutofbounds, memoryerror, timelimit error, etc.), please read this comment https://wcipeg.com/problem/p108ex9#comment9195

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

Oops lol. I accidentally added in the 6 at the beginning when I calculated the median, meaning I had the numbers 6 18 28 37 40 49 and 69, meaning the median I calculated was 37. Sorry about the clumsy mistake.

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