Time complexity of a 2-heap question
Store the window in a balanced binary search tree.  Each time a value arrives, add it to the tree, remove the one leaving the window, compute the median, and output it.  Each of those operations can be done in $O(\log k)$ time, so the total running time to process $n$ items will be $O(n \log k)$.