As scores stream in live during the contest, Wasif's live scoreboard must report the running MEDIAN score after each new submission arrives. Process N integers one at a time (arriving in the given order). After each insertion, print the current median of all numbers seen so far (if even count, print the average of the two middle values, as a value with up to 1 decimal place if needed). Use two heaps (or an ordered structure) for O(log N) per insertion, not a full re-sort each time.
Input
Line1: N. Line2: N integers (the stream, in order).
Output
N lines: median after each insertion.
Constraints
1 ≤ N ≤ 10^5
Sample Input
3 5 15 1
Sample Output
5 10 5
main.c
Loading editor…
Write C, then Run (custom I/O) or Submit (sample tests). ⌘/Ctrl+Enter submits.