We show that $h$ must be in $R[x]$. Suppose that we have polynomials
$$g = x^n + a_1x^{n-1} + ... + a_n \in R[x]$$ $$h = x^m +b_1x^{m-1} + ... + b_m \in K[x]$$ such that $f = gh \in R[x]$ but $h \notin R[x]$. Let $r:= \min \{i \mid b_i \notin R\}$. Since $f \in R[x]$ we have $b_r + a_1b_{r-1} + ... + a_{r-1}b_1 + a_r \in R$, so $b_r \in R$. It is a contradiction.