An exercise on an integral inequality I need help with this exercise:
let   $f,g,h : [0,1]  \to  [0,\infty] $ integrable functions. Prove that the following statements are equivalent:
i) $(f(x))^2 \leq g(x)h(x) $ almost everywhere. 
ii) For every measurable set $E \subset [0,1] $ we have:
$$\left(\displaystyle\int_E f(x)dx\right)^2 \leq \displaystyle\int_E g(x)dx\displaystyle\int_E h(x)dx.$$ 
I proved that $ i) \Rightarrow ii) $ with Holder inequality, but i have some problems with the other implication.

Consider the polynomial 
$$P_E(t):=\left(\int_E h(x)dx\right)t^2+2\left(\int_E f(x)dx\right)t +\left(\int_E g(x)dx\right)$$
For each $E$, we have that the leading coefficient is non-negative with non-positive discriminant. Moreover, when $\int_E h(x)dx=0$ we have $\int_E f(x)dx=0$, so even in that case $P_E(t)=\int_Eg(x)dx\geq0$.
Then $$\int_E\left(t^2h(x)+2tf(x)+g(x)\right)dx\geq0$$ for all $E$. It follows that $$q_x(t):=t^2h(x)+2tf(x)+g(x)\geq0\ \ \ \ a.e.\ (\text{in }x)$$

Delicate point: So, for each $t\in\mathbb{Q}$ there is a set of measure zero $A_t$. This means that for each $x\in A:=[0,1]\setminus\bigcup_{t\in\mathbb{Q}}A_t$ and all $t\in\mathbb{Q}$ we have that $q(t)\geq0$. Notice that the measure of $[0,1]\setminus A=\bigcup_{t\in\mathbb{Q}}A_t$ is zero because it is a countable union of sets of measure zero..

Therefore, for each $x\in A$, the discriminant is non-positive, i.e. $$(f(x))^2\leq h(x)g(x)\;\text{ for }\;x\in A.$$
