In the question it is said that the spring is stretched by a distance x beyond its equilibrium position. So the origin of the coordinate system in question is the equilibrium position and not the un-stretched position (and I think you took the origin to be the ceiling). If I put $x=y-(l_0+l_1)$$x=y-l_1=y-l_0-(l_1-l_0)$ in the question, then $$U(y)=const+\frac{k(y-l_0-l_1)^2}{2}=cosnt+kl_1^2/2+\frac{k(y-l_0)^2}{2}-kl_1(y-l_0)$$$$U(y)=const+\frac{k(y-l_0-(l_1-l_0))^2}{2}=cosnt+k(l_1-l_0)^2/2+\frac{k(y-l_0)^2}{2}-k(l_1-l_0)(y-l_0)$$ which I think resemble your answer. So you did everything correct including the mathematics. It's just that your coordinate system doesn't match with the coordinate system of the question. If you take the potential to be zero at equilibrium position, you will get the correct form.