If a projectile is launched at a speed u from a height H above the horizontal axis, and air resistance is ignored, the maximum range of the projectile is Rmax=ugu2+2gH−−−−−−−−√, where g is the acceleration due to gravity.
The angle of projection to achieve Rmax is θ=arctan(uu2+2gH√)