In the case of maximum elongation, whole system will be moving with a common acceleration
a, so for the system
F=(m+m)a⇒a=‌...(i)
The centre of mass of the system will also move with the same acceleration
a.
Let us suppose that both the masses elongate the spring by a distance
x1 and
x2, respectively. So, on taking the frame of centre of mass there will act a pseudo force equal to
ma on the masses.
On applying the work-energy theorem, taking the centre of mass as a reference point.
W‌all forces ‌=∆K [∵ w.r.t. centre of mass
∆K=0] ⇒‌‌x1+x2=‌⇒x‌total ‌=‌ Here,
F=10N,K=2500N/m2 So,
So, the maximum distance between the blocks will be
= natural length
+x‌total ‌ =10cm+0.4cm=10.4cm [∵ Natural length
=10cm (given)]