C++ implementation for Sequence Median problem