The correct option is B.
We have,
mass=m
According to the law of conservation of energy for the spring system
so,
Initial total energy = final total energy
Potential energy = kinetic energy + spring elastic energy
Now if x be an elongation of the spring,
Then,
mgx=(12)mv2+(12)kx2
Now, the maximum elongation corresponds to the point where the velocity becomes zero and the spring is about to turn backward.
So, by putting v=0 in the above relation we get
mgx=(12)kx2
Thus, the maximum elongation would be
x=2mgk