5. It is known that the hourly fuel consumption of a certain aircraft in flight is directly proportional to the cube of its speed. When the aircraft flies at a speed of $a$ km/h, its fuel cost is $m$ yuan (the price of fuel is a constant). In addition, the other costs for the aircraft to fly for 1 hour, apart from the fuel cost, are $n$ yuan. Try to find the most economical speed and the total cost for the aircraft to fly $p$ kilometers.

---

The translation maintains the original text's line breaks and format as requested.
5. Let the most economical speed be $x$ kilometers/hour, and let the fuel cost for 1 hour be $y_{1}$ yuan, then $y_{1}=k x^{3}$. When $x=a$, $y_{1}=m$, we get $k=\frac{m}{a^{3}}$, i.e., $y_{1}=\frac{m x^{3}}{a^{3}}$. The total cost for flying $p$ kilometers is $y=\left(\frac{m x^{3}}{a^{3}}+n\right) \cdot \frac{p}{x}=$ $p\left(\frac{m x^{2}}{a^{3}}+\frac{n}{x}\right)=p\left(\frac{m x^{2}}{a^{3}}+\frac{n}{2 x}+\frac{n}{2 x}\right) \geqslant \frac{3 p}{a} \sqrt[3]{\frac{m n^{2}}{4}}$, with equality holding if and only if $\frac{m x^{2}}{a^{3}}=\frac{n}{2 x}$, i.e., $x=a$. $\sqrt[3]{\frac{n}{2 m}}, y_{\min }=\frac{3 p}{a} \cdot \sqrt[3]{\frac{m n^{2}}{4}}$.