For this case we have the following function:

To find the distance between the pillars, we must match the equation to zero:

From here, we clear the value of d:

The roots are:
Root 1:

Root 2:
Thus, the pillars are 40 units away.
The maximum height, we obtain it by deriving:

We equal zero and clear d:

Then, we substitute the value of d = 20 in the equation for the height:
The maximum height is 10 units of distance