Using conservation of energy we find the velocity of ball A just before impact when it has fallen a vertical distance 4h:
2mg(5h-h)= 1 2 .2m. uA 2

so uA =8gh. By conservation of momentum at the impact, taking the velocities of the balls before and after impact to be uA , vA and uB =0, vB :
2 muA =2 mvA + mvB

and using the coefficient of restitution:
0.5 uA = vB - vA

From these two equations: vB = uA =8gh and vA =0.5 uA .

The time t before B hits the ground is given by:
h= 1 2 gt2

so
t= 2h g .

The horizontal distance traveled in this time is given by:
d=8gh× 2h g =4h.