You take the vertical component of the starting velocity and apply gravity (32.2) multiplied by time to reach zero vertical velocity. Then 1/2 a*t squared to get the height.
Given an angle of 45 degrees, which I assume to be optimal in the way of distance, and a distance of 40 miles, can we derive apex? Can we do this without velocity component?