$f,g$ are monotonically increasing in $[0,1]$ and $0\le f , g \le 1$. $\int_0^1 f - g \mathrm{d}x = 0$. Prove that
$$\int_0^1 |f - g|\mathrm{d}x \le \frac{1}{2}$$
In my previous question, $g(x) = x$. And my teacher said $x$ can be replaced by $g(x)$. In fact, in previous question, we don't need to use the condition $\int_0^1 f - g \mathrm{d}x = 0 $. But if we replace $x$ with $g$, this condition becomes necessary.
Also, if $g = x$, we can replace the $\frac{1}{2}$ with $\frac{1}{4}$,that is
$$\int_0^1|f-g| \mathrm{d}x \le \frac{1}{4}$$ I am wondering how to prove that.
Let $f=\mathbf1_{[\frac12,1]}$, $g=\frac12$, then $\int|f-g|=\frac12$. Except for swapping $f,g$, this is the only case to reach the maximum.
We can decompose $f-g=(f-g)^+-(f-g)^-$ where $h^+=\max(0,h),h^-=-\min(h,0)$. So $\int (f-g)^+=\int(f-g)^-$.
$f,g$ is monotone means $f-g$ has bounded variation, in particular $V(f-g)\le V(f)+V(g)\le2$.
So $\sup(f-g)^++\sup(f-g)^-\le1$. To see we can assume $f(0)=g(0)=0,f(1)=g(1)=1$ since we don't assume $f,g$ to be continuous. And for simplicity assume supermum can be taken, say $f(a)-g(a)=\max(f-g)$, $f(b)-g(b)=\min(f-g)$.
Assume $a<b$ otherwise swap $f,g$. Then $V(f-g)=V_0^a(f-g)+V_a^b(f-g)+V_b^1(f-g)\ge(\max-0)+(\max-\min)+(0-\min)=2(\max-\min)=\sup(f-g)^++\sup(f-g)^-$.
Then use $\int|f-g|=\int_{(f>g)}(f-g)^++\int_{(f<g)}(f-g)^-=2\int_{(f>g)}(f-g)^+=:2I$.
And we have $I\le m(f>g)\cdot\sup(f-g)$, $I\le m(f<g)\cdot\sup(g-f)$ with $m(f>g)+m(f<g)\le1$, $\sup(f-g)+\sup(g-f)\le1$.
If $I>\frac14$, $m(f>g)\sup(f-g)\ge I$, then $m(f<g)\sup(g-f)\le(1-m(f>g))(1-\max(f-g))\le1+m(f>g)\sup(f-g)-(m(f>g)+\sup(f-g))\le 1+I-2\sqrt I=(1-\sqrt I)^2<I$, contradiction.