Using the work-energy theorem, the total work done by all forces is equal to the change in kinetic energy (\(\Delta KE\)) of the system. Here:
\[w_g + w_{Fr} + w_s = \Delta KE.\]
Substituting the given values:
\[5 \times 10 \times 5 - 0.5 \times 5 \times 10 \times x - \frac{1}{2} Kx^2 = 0 - 0.\]
Simplifying:
\[250 - 25x - 50x^2 = 0.\]
Rewriting:
\[2x^2 + x - 10 = 0.\]
Solving this quadratic equation gives:
\[x = 2.\]
Thus, the maximum compression in the spring is \(x = 2\) m.