Two invariants to maintain:
Size balance: the heaps' sizes differ by at most . If they differ, the larger heap has the median.
Value ordering: all elements in max-heap (smaller half) are all elements in min-heap (larger half). Insertion strategy:
- Add to max-heap first (smaller half)
- Move max-heap's root to min-heap (ensure ordering)
- If min-heap is larger, move its root back to max-heap (ensure balance)