Navigation resource allocation for low-earth-orbit (LEO) constellations refers to the optimal allocation of navigational assets when the number and allocation of satellites in the LEO constellation have been determined. LEO constellations can not only transmit navigation enhancement signals but also enable space-based monitoring (SBM) for real-time assessment of GNSS signal quality. However, proximity in the frequencies of LEO navigation signals and SBM can lead to significant interference, necessitating isolated transmission and reception. This separation requires that SBM and navigation signal transmission be carried out by different satellites within the constellation, thus demanding a strategic allocation of satellite resources. Given the vast number of satellites and their rapid movement, the visibility among LEO, medium-earth-orbit (MEO), and geostationary orbit (GEO) satellites is highly dynamic, presenting substantial challenges in resource allocation due to the computational intensity involved. Therefore, this paper proposes an optimal allocation algorithm for LEO constellation navigation resources based on dynamic programming. In this algorithm, a network model for the allocation of navigation resources in LEO constellations is initially established. Under the constraints of visibility time windows and onboard transmission and reception isolation, the objective is set to minimize the number of LEO satellites used while achieving effective navigation signal transmission and SBM. The constraints of resource allocation and the mathematical expression of the optimization objective are derived. A dynamic programming approach is then employed to determine the optimal resource allocation scheme. Analytical results demonstrate that compared to Greedy and Divide-and-Conquer algorithms, this algorithm achieves the highest resource utilization rate and the lowest computational complexity, making it highly valuable for future resource allocation in LEO constellations.