I found this statement in a book, given without proof and left as an exercise to the reader.
Theorem: Suppose $f$ is a continuous and strictly increasing function on $[a,b].$ Let $m=(a+b)/2$. Then the unique minimum of $\int_a^b |f(t)-x|\, dt$ over $x\in \mathbb {R}$ is $$\int_m^b f(t)\,dt - \int_a^m f(t)\,dt$$ and occurs at $x=f(m).$
Is there an elementary proof of this statement? It is not homework, but I really do not see how I can establish a proof.
If $x < f(a)$ or $x > f(b)$, it is clear that
$$\int_a^b \lvert f(t)- x\rvert\,dt > \int_a^b \lvert f(t) - f(c)\rvert\,dt,$$
where $c$ is $a$ if $x < f(a)$ and $b$ if $x > f(b)$.
So we need only look at $f(a) \leqslant x \leqslant f(b)$. By the intermediate value theorem, $x = f(\xi)$ for a $\xi\in [a,b]$. Now
$$\begin{align} \int_a^b \lvert f(t) - f(\xi)\rvert\,dt &= \int_a^\xi f(\xi)-f(t)\,dt + \int_\xi^b f(t) - f(\xi)\,d\xi\\ &= \int_\xi^b f(t)\,dt - \int_a^\xi f(t)\,dt + f(\xi)\left((\xi-a) - (b-\xi)\right)\\ &= (2\xi-(a+b))f(\xi) + \int_\xi^b f(t)\,dt - \int_a^\xi f(t)\,dt.\tag{1} \end{align}$$
If $f$ were differentiable, differentiating $(1)$ would give
$$\frac{d}{d\xi} \int_a^b\lvert f(t)-f(\xi)\rvert\,dt = (2\xi-(a+b))f'(\xi),$$
and the additional assumption $f' > 0$ would establish the unique global minimum for $\xi = \frac{a+b}{2}$.
But, since $f$ is only assumed continuous, differentiating is problematic, so we consider the difference for $a \leqslant \xi < \zeta \leqslant b$. Since nothing is changed by adding a constant to $f$, or translating the interval, we may, for ease of notation, assume $a = -b$ and $f(0) = 0$. Then
$$\begin{align} \int_{-b}^b \lvert f(t)-f(\zeta)\rvert\,dt - \int_{-b}^b \lvert f(t)-f(\xi)\rvert\,dt &= 2(\zeta f(\zeta)-\xi f(\xi)) - 2\int_\xi^\zeta f(t)\,dt. \end{align}$$
If we choose $\xi = 0$, the difference becomes
$$2\zeta f(\zeta) - 2\int_0^\zeta f(t)\,dt = 2\int_0^\zeta f(\zeta)-f(t)\,dt > 0,$$
and for $\zeta = 0$, it becomes
$$-2\xi f(\xi) - 2 \int_\xi^0 f(t)\,dt = 2 \int_\xi^0 f(\xi) - f(t)\,dt < 0,$$
showing that indeed the choice $x = f(0)$ - or generally $x = f\left(\frac{a+b}{2}\right)$ - yields the unique global minimum.