The distance travelled by ball $A$, ${h_1} = \frac{1}{2}g{t^2}$
The distance travelled by ball $B$, ${h_2} = ut - \frac{1}{2}g{t^2}$
${h_1} + {h_2} = 400\;m$
$⇒$ $ut = 400,\;t = 400/50 = 8\;sec$
$\therefore {h_1} = 320\;m\;\;{\rm{and}}\;\;{h_2} = 80\;m$