If it travels the max possible distance, means θ = 45
0 means v
x = vSin 45 = v
y
a = v / T , in this case -g = -vy / T or g = vy / T
This T, is the time required for the ball to reach the highest point in the air, it takes the same time for the ball to reach the ground again.
Means, t = 2T
So, g = vy / T = vx / T
g = (vx / t) / 2
g = 2vx / t
g = 2vSinθ / t
Hope it helps