Let H be the total height of the building.
Let stone 1 be the one dropped from the top, and stone 2 be the one dropped from 25 m below the top.
First, find the velocity ($v_1$) of stone 1 when it has fallen 5 m.
Using $v^2 = u^2 + 2gs$, with initial velocity $u=0$ and distance $s=5$ m:
$v_1^2 = 0 + 2g(5) = 10g \implies v_1 = \sqrt{10g}$.
At this moment, stone 2 is dropped. Let 't' be the time it takes for both stones to reach the ground from this point.
For stone 1, the remaining distance is $(H - 5)$ m.
Using $s = ut + \frac{1}{2}gt^2$: $H - 5 = (\sqrt{10g})t + \frac{1}{2}gt^2$. (Equation 1)
For stone 2, the distance to fall is $(H - 25)$ m, starting from rest.
$H - 25 = (0)t + \frac{1}{2}gt^2 \implies H - 25 = \frac{1}{2}gt^2$. (Equation 2)
Substitute the expression for $\frac{1}{2}gt^2$ from Equation 2 into Equation 1:
$H - 5 = (\sqrt{10g})t + (H - 25)$.
Simplifying gives: $20 = \sqrt{10g} \cdot t$, so $t = \frac{20}{\sqrt{10g}}$.
Now, substitute this value of t back into Equation 2:
$H - 25 = \frac{1}{2}g \left(\frac{20}{\sqrt{10g}}\right)^2 = \frac{1}{2}g \left(\frac{400}{10g}\right) = \frac{40}{2} = 20$.
$H - 25 = 20 \implies H = 45$ m.
The height of the building is 45 m.