Solution (source code)

= Solution

The number $K$ is fixed. By <Big O notation>, for each $i$ there are constants $C_i>0$ and $N_i$ such that $f_i(n)\leq C_i g(n)$ when $n\geq N_i$. Take $N=\max_iN_i$. For $n\geq N$, positivity gives
$$
h(n)\leq\left(\sum_{i=1}^K C_i\right)g(n),
\qquad
l(n)\leq\left(\sum_{i=1}^{K-1}C_iC_{i+1}\right)g(n)^2.
$$
The constants in parentheses are independent of $n$, proving $\boxed{h=O(g),\quad l=O(g^2)}$. If $K=1$, the second sum is empty and $l=0$, which satisfies the same upper bound.