5. In a box with a height of $4 \mathrm{~cm}$ and a base side length of $18 \mathrm{~cm}$, standard size table tennis balls with a diameter of $40 \mathrm{~mm}$ are placed. Then the maximum number of table tennis balls that can be placed is ( ) .
(A) 16
(B) 18
(C) 20
(D) 23
5.C.

Let the base square be $A B C D$, the radius of the sphere be $r, r=2 \text{ cm}$. Since the height of the box is just enough to fit one ping-pong ball, we only need to consider the horizontal arrangement.

Now, consider a certain arrangement of ping-pong balls as shown in the top view in Figure 6, where the balls are tangent to each other. Therefore, the centers $\mathrm{O}_{1}, \mathrm{O}_{2}, \mathrm{O}_{3}$ form an equilateral triangle with side length $2 r$ and height $\sqrt{3} r$. Let the rectangle that is tangent to the outer edges of the balls be $A^{\prime} B^{\prime} C^{\prime} D^{\prime}$. The figure shows:
$$
\begin{array}{l}
A^{\prime} D^{\prime}=9 r=18 \text{ cm}, \\
A^{\prime} B^{\prime}=2 r+4 \sqrt{3} r=4+8 \sqrt{3} \approx 17.864<18(\text{ cm}),
\end{array}
$$

Thus, the rectangle $A^{\prime} B^{\prime} C^{\prime} D^{\prime}$ is contained within the base square $A B C D$. This arrangement can fit 20 ping-pong balls, and all other arrangements fit fewer than 20.