Naval gunfire is known for it’s flat trajectory.
At high enough angles of elevation, a 5-inch gun can be fired as it were a mortar. The fire control computers can handle reverse-slope fire. (Worst case, the chief can crank in some ACTH.)
Do you think that is how the 5"/54 caliber Mark 45 gun reaches 20+ miles, on a flat trajectory?
Besides, as explained the gun on the Zumwalt isn't conventional: link