For the centroid
$\overline{x} = \dfrac{\sum\limits_{i}{m_i x_i}}{\sum\limits_{i}{m_i}}$.
Since the average mass is fixed, we have that the denominator equals $15w$.
So we need to maximise the magnitude of the numerator. This can be done by placing men of mass $2w$ in the six positions to the right of the centerline, six men of mass $0$ to the left of the centerline and men of average mass $w$ (e.g. 0, $w$, $2w$) on the centerline. Assume the long side of the dead man's chest has length $l$, then
$\overline{x} = \dfrac{3w\cdot0 + 3\cdot2w\cdot0.25l + 3\cdot2w\cdot{0.5l}}{15w} = \dfrac{4.5wl}{15w} = 0.3l = 1.2a$
(to the right of the centerline).
It is easily seen that the mass of the men of the centerline does not matter as it has no moment about the centerline, while reducing the mass of any men on the right will shift the centroid leftward, so this is the maximal distance.