10107-what is the Median?
Time limit:3.000 seconds
Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem &problem=1048
The Problem
Median plays an important is in the world of statistics. By definition, it's a value which divides an array into two equal parts. In this problem your are to determine the current median of some long integers.
Suppose, we have five numbers {1,3,6,2,7}. In this case, the 3 are the median as it has exactly two numbers on their 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 the split this array into the equal two parts, so we Consider the average of the middle values {3,6}. Thus, the median would be (3+6)/2 = 4.5. In this problem, your have to print is the integer part and not the fractional. As a result, according to this problem, the median would be 4!
Input
The input file consists of series of integers x (0 <= x < 2^31) and total number of integers N is less than 10000. The numbers may have leading or trailing spaces.
Output
For each input print the current value of the median.
Sample Input
1
3
4
2
Sample Output
1
2
3
3
4
4