#YSS83. 奇数项中位数-Median odd-numbered items
奇数项中位数-Median odd-numbered items
The past that is gone, don't look back at it, the past that is gone.
--- Lost Lamb
Background
In the fields of data analysis and algorithms, the median is a very important statistical indicator that reflects the central tendency of a dataset. It performs well in handling outliers, unlike the mean which is easily affected. In practical applications such as financial analysis, medical research, and quality control, there is often a need to dynamically calculate the median of a data stream, especially when new data is continuously arriving.
This task involves calculating the median of the first few odd-numbered items based on a growing sequence. Imagine a real-time monitoring system that receives a series of non-negative integer data. The system needs to immediately calculate and output the median after receiving each odd-numbered item, so that it can make quick responses and adjustments. The core of this problem is how to efficiently find the median of a dynamic data stream, especially when the amount of data is very large.
Problem Description
Given a sequence of non-negative integers of length , calculate and output the median of the current odd-numbered items each time a new odd-numbered item is added.
Input Format
- The first line contains a positive integer , indicating the length of the sequence.
- The second line contains non-negative integers , representing the elements in the sequence.
Output Format
Output lines. The -th line outputs the median of the sequence .
Sample #1
Sample Input #1
7
1 3 5 7 9 11 6
Sample Output #1
1
3
5
7
Sample #2
Sample Input #2
7
3 1 5 9 8 7 6
Sample Output #2
3
3
5
6
Hints
For 20% of the data, ;
For 40% of the data, ;
For 100% of the data, , .