荔园在线

荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀

[回到开始] [上一篇][下一篇]


发信人: kaman (天外飞仙), 信区: ACMICPC
标  题: Sequence Median
发信站: 荔园晨风BBS站 (Sun Mar 28 11:46:34 2004), 站内信件

Sequence Median
Time Limit: 1.0 second
Memory Limit: 1 000 КБ

Given a sequence of N nonnegative integers. Let's define the median of
such sequence. If N is odd the median is the element with stands in the
middle of the sequence after it is sorted. One may notice that in this
case the median has position (N+1)/2 in sorted sequence if sequence elements
 are numbered starting with 1. If N is even then the median is the
semi-sum of the two "middle" elements of sorted sequence. I.e. semi-sum of
the elements in positions N/2 and (N/2)+1 of sorted sequence. But original
sequence might be unsorted.

Your task is to write program to find the median of given sequence.

Input
The first line of input contains the only integer number N - the length of
the sequence. Sequence itself follows in subsequent lines, one number in a
line. The length of the sequence lies in the range from 1 to 250000. Each
element of the sequence is a positive integer not greater than 2^32 - 1
inclusive.

Output
You should print the value of the median with exactly one digit after
decimal point.

Sample Input
4
3
6
4
5

Sample Output
4.5

--
Long long ago,there is a hero stand at the edge of the land.......

     ▁▁
   ▕天外▏
   ▕飞仙▏
     ▔▔

※ 来源:·荔园晨风BBS站 bbs.szu.edu.cn·[FROM: 192.168.111.157]


[回到开始] [上一篇][下一篇]

荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店