Finding the angle that gives longest path for projectile motion using the average speed over the vertical displacement of object

For projectile motion, let's say a ball is launched at an angle a with respect to the horizontal, upwards.

If I want to find an expression for the length of the path travelled by the ball before it hits the ground again, this is my approach:

1. Find expression for v in terms of sy, the vertical displacement of the ball, for the first half of the projectile motion.

2. Integrate v with respect to sy, then divide the integral obtained by the maximum height. This gives me average speed over the displacement sy.

3. Find the time taken to travel full horizontal range.

4. Multiply average speed with time taken to travel its full horizontal range, to get expression for path travelled.

When I find the expression for path travelled, and differentiate with respect to the angle a of launch, and equate that to zero to find possible values of a, I get 68.529 degrees. ie if projectile is launched at an angle 68.529 degrees from horizontal, it travels maximum path length.

But the correct answer is 56.4658 degrees. But not sure why this method I've used is wrong. Is it wrong to say that the average speed over the vertical displacement is not equal to the average speed over time? If so, why?

Consider linear acceleration $$v=at$$ from $$t=0$$ to $$t=T$$. Then averages: $$\left_t = \frac 1T\int_0^Tat\ dt=\frac12aT,\\ \left_s = \frac 1S\int_0^Sat(s)\ ds= \frac 2{aT^2}\int_0^{aT^2/2}a\sqrt{\frac{2s}{a}}\ ds = \frac23 aT.$$
On a side note, “averaging” is a type of statistics that depends on the underlying metric (which is arbitrary in many soft science cases, so ranked statistics like median is often a better choice). You can get intuition why it's so by thinking of integral $$\frac 1T\int v dt$$ as averaging of values $$v_1$$, $$v_2$$, $$v_3\ldots$$ with weights $$\frac{dt_1}T$$, $$\frac{dt_2}T$$, $$\frac{dt_3}T$$... When you change the variable $$t\to s$$, you keep the values $$v$$ the same, but weights are changed $$\frac{ds}S=\frac TSs'(t)\frac{dt}T$$. The weights still sum to 1 (as they should in a weighted average), but the average still be different (unless $$s'(t)$$ is constant): $$\frac13v_1+\frac13v_2+\frac13v_3 \neq \frac16v_1+\frac13v_2+\frac12v_3$$