Answer
The speed of the block of mass $m$ is $3\times \sqrt{\frac{k~D^2}{12~m}}$
The speed of the block of mass $3m$ is $\sqrt{\frac{k~D^2}{12~m}}$
Work Step by Step
Since the spring is compressed a distance $D$, the energy in the system is $\frac{1}{2}k~D^2$ which is stored as elastic potential energy in the spring.
Let $v_A$ be the speed of the block of mass $m$. Let $v_B$ be the speed of the block of mass $3m$. We can use conservation of momentum to set up an equation.
$m~v_A = 3m~v_B$
$v_A = 3~v_B$
We can use conservation of energy to find the speeds of the two blocks.
$KE = EPE$
$\frac{1}{2}m~v_A^2 + \frac{1}{2}(3m)~v_B^2 =\frac{1}{2}k~D^2$
$m~(3v_B)^2 + 3m~v_B^2 =k~D^2$
$v_B^2 = \frac{k~D^2}{12~m}$
$v_B = \sqrt{\frac{k~D^2}{12~m}}$
We can use $v_B$ to find $v_A$.
$v_A = 3~v_B = 3\times \sqrt{\frac{k~D^2}{12~m}}$
The speed of the block of mass $m$ is $3\times \sqrt{\frac{k~D^2}{12~m}}$
The speed of the block of mass $3m$ is $\sqrt{\frac{k~D^2}{12~m}}$