5. The number of students in the first and second grades of a school is the same, and the number of students in the third grade is $\frac{4}{5}$ of the number of students in the second grade. It is known that the number of boys in the first grade is the same as the number of girls in the second grade, and the number of boys in the third grade accounts for $\frac{1}{4}$ of the number of boys in the three grades. Therefore, the proportion of the number of girls in the three grades to the total number of students in the three grades is ( ).
(A) $\frac{9}{19}$
(B) $\frac{10}{19}$
(C) $\frac{11}{21}$
(D) $\frac{10}{21}$
5.G.

According to the problem, the data in the question can be represented by Table 1.

From the problem, we know that $x = \frac{1}{4}(b + a - b + x)$.
Solving this, we get $x = \frac{a}{3}$.
\begin{tabular}{|c|c|c|c|}
\hline & Grade 7 & Grade 8 & Grade 9 \\
\hline Boys & $b$ & $a-b$ & $x$ \\
\hline Girls & $a-b$ & $b$ & $\frac{4}{5} a - x$ \\
\hline Total & $a$ & $a$ & $\frac{4}{5} a$ \\
\hline
\end{tabular}

Therefore, the number of girls in Grade 9 is
$\frac{4}{5} a - x = \frac{4}{5} a - \frac{a}{3} = \frac{7}{15} a$.
Thus, $\frac{a + \frac{7}{15} a}{a + a + \frac{4}{5} a} = \frac{11}{21}$, which is the ratio of the number of girls in the three grades to the total number of students in the three grades.