Loading repovive.com/problems/classics/61
Read numbers one by one. After each insertion, print the current median. When the count is even, print the lower of the two middle values.
5 5 1 9 3 7
The sorted prefixes have lower medians 5, 1, 5, 3, and 5 after the five insertions.
5 1 5 3 5
4 -2 -2 10 0
After each insertion, the lower middle value of the sorted prefix remains -2.
-2 -2 -2 -2
3 1 2 3
The sorted prefixes are
[1]
,
[1, 2]
, and
[1, 2, 3]
, so the lower medians are 1, 1, and 2.
1 1 2