问题 2484 --median

2484: median

题目描述

  Median plays an important role in world of statistics. By definition, it is a value which divides an array into two equal parts. In this problem you are to determine the current median of some long integers.
Suppose, we have five numbers {1,3,6,2,7}. In this case, 3 is the median as it has exactly two numbers on its each side. {1,2} and {6,7}.

If there are even number of values like {1,3,6,2,7,8}, only one value cannot split this array into equal two parts, so we consider the average of the middle values {3,6}. Thus, the median will be (3+6)/2 = 4.5. In this problem, you have to print only the integer part, not the fractional. As a result, according to this problem, the median will be 4.

输入

The input file consists of series of integers X ( 0 <= X < 2^31 ) and total number of integers N is less than 20000. The numbers may have leading or trailing spaces.

输出

For each input print the current value of the median.

样例输入输出

输入#1 复制
1
3
4
60
70
50
2
输出#1 复制
1
2
3
3
4
27
4

提示

对于这类题目,输入可以采用如下的方式:

int n;
while(scanf("%d", &n) != EOF){
    your code...
}
这是根据scanf的返回值来判断循环结束,有兴趣的同学可以自己查阅相关资料

序号 标题 作者 发表时间 费用 订购数 操作