About a continuous function satisfying a given integral equation 
Question: Let $f(x):[0,2] \to \mathbb{R}$ be a continuous function, satisfying the equation
  $$
\int_{0}^{2} f(x)(x-f(x)) \,dx = \frac{2}{3}.
$$
  Find $2f(1)$.

The solution took $f(x)=\frac {x}{2}$. Yes, I know it does not contradict the condition but how can we be sure that $f(x)=\frac{x}{2}$ and not any other function?

By A.M-G.M inequality we have $$f(x)(x-f(x))\leq \Big({f(x)+x-f(x)\over 2}\Big)^2 = {x^2\over 4}$$
so we always have $$
\int_{0}^{2} f(x)(x-f(x)) \,dx \leq \int_{0}^{2} {x^2\over 4} \,dx=\frac{2}{3}.
$$
Since we have equality we have $f(x)=x-f(x)$ for each $x$ and we are done (remember that we have equality in A.M-G.M iff numbers are equal).
