Let $f$ be continuous on $\mathbb R$, and satisify $$f(x)\leq \frac{1}{2h}\int_{-h}^h f(x+t)d t, \forall\ h>0.$$ Show that $f$ is convex.
The original question is "if and only if". However, I could only prove on part. But the other part (this question) is this problem. I want to show that $$f((x+y)/2)\leq (f(x)+f(y))/2$$ from $$f(x)\leq \frac{1}{2h}\int_{-h}^h f(x+t)d t, \forall\ h>0.$$ However, I have no idea.
Let $\delta>0$ and define $$ f_\delta(x)=\frac{1}{\delta^2}\int_{-\delta}^\delta \lvert s\rvert\,f(x+s)\,ds. $$ Then $f_\delta$ twice continuously differentiable, and $f_\delta\to f$ uniformly in compact sets.
Next, we can readily obtain that $$ f_\delta(x)\le\frac{1}{2h}\int_{-h}^hf_\delta(x+t)\,dt, $$ which implies that for all $h>0$: $$ \int_{-h}^h\big(f_\delta(x+t)-f_\delta(x)\big)\,dt= \int_0^h\big(\,f_\delta(x+t)-2f_\delta(x)+f_\delta(x-t)\big)\ge 0. $$ But $$ \int_0^h\big(\,f_\delta(x+t)-2f_\delta(x)+f_\delta(x-t)\big)=\int_0^h \Big(\int_0^t \big(\,f'_\delta(x+\tau)-f'_\delta(x-t+\tau)\big)\,d\tau\Big)\,dt \\= \int_0^h \Big(\int_0^t \big(\,\int_{-t}^0 f''_\delta(x+\tau+s)\,ds\big)\,d\tau\Big)\,dt $$ and hence, for all $h>0$: $$ \int_0^h \Big(\int_0^t \big(\,\int_{-t}^0 f''_\delta(x+\tau+s)\,ds\big)\,d\tau\Big)\,dt\ge 0, $$ which implies that $$ f''_\delta(x)\ge 0, $$ for all $x$.
Hence $f_\delta$ is convex, and so is $f$, as a locally uniform limit of $f_\delta$, as $\delta\searrow 0$.