With a 5 kg mass hanging at rest from the spring of constant k = 250 N/m, the stretch of the spring will be X = mg/k =5(9.8)/250 = 0.196 m. With (x) measured positive down from the un-stretched position, and gravitational potential energy chosen to be zero when x = 0, then then the energy of the 10 kg mass is (1/2)(10)$2.5^2$ + (1/2)(250)$0.196^2$ - 10(9.8)(0.196) = (1/2)(250)$x^2$ -10(9.8)x. (x when v = 0) Or: 125$x^2$ - 98x – (31.25 +4.802 – 19.208) = 0. Solving gives x = - 0.145 m. (The other xsolution is for initial velocity downward). Since positive x was measured down, this negative x represents a compression of the spring above the un-stretchedunstretched position. Then the total rise is 0.196 + 0.145 = 0.341 m. For the record, if the moving mass is the same as the hanging mass: then mg = kX and (1/2)m$v^2$ + (1/2)k$X^2$ - (kX)X = (1/2)k$x^2$ - (kX)x. Or rearranged: (1/2)m$v^2$ = (1/2)k$(X^2 – 2Xx + x^2) = (1/2)k(X-x)^2$. Lets try ignoring gravity with x measured from a 10 kg hanging position (which is an additional 0.196m further down): (1/2)(10)$2.5^2$ + (1/2)(250)$0.196^2$ = (1/2)(250)$x^2$. Rearranging: 125$x^2$ = (31.25 + 4.802) Giving x = 0.537. With the starting position 0.196 m above the new equilibrium, this gives a rise of 0.341 m. The bottom line: A mass hanging from a spring defines a new equilibrium position. The kx measured from that position includes the force of gravity (but don't change the mass). Here is an alternative approach: With the stretch of the spring (x) measured positive down from the unstretched position, the net force on the hanging mass is: F = mg - kx Then dF = - k(dx). Integrating both sides gives F(x) - $F_o$ = -k(x - $x_o$). If starting from the new equilbrium then $F_o$ =0.