Problem 3107 · Medium
Sort the numbers and pay only for the half of the array that must move so the median lands on k.
Open the interactive visualisation