The gravitational potential energy of a body with mass m at a height h is equal to m*g*h where g is the gravitational acceleration. The potential energy stored in a spring that is compressed or pulled by x from its equilibrium length is (1/2)*k*x^2 where k is the spring constant.
A mass of 10 kg is dropped from a height of 18 m on a spring with spring constant 10 N/m. If the original length of the spring was given, a more accurate value for the compression could have been determined. As this is not given, assume the entire gravitational potential energy of mass is stored as energy in the spring.
10*9.8*18 = (1/2)*10*x^2
=> 9.8*18*2 = x^2
=> x^2 = 352.8
=> x = 18.78 m
The spring is compressed by approximately 18.78 m