Work done = $\large\frac{1}{2} \times$ stress $\times$ strain $\times$ volume
$\qquad= \large\frac{1}{2}$$ \times Y \times (strain )^2 \times Volume $
$\qquad =\large\frac{1}{2}$$ \times Y \times \bigg( \large\frac{x}{L}\bigg)^2$$ \times AL$
$\qquad= \large\frac{Yx^2A}{2L}$
Hence b is the correct answer.