Example 4 In space, there are 2003 points, where no three points are collinear. Divide them into 30 groups with different numbers of points. From any three different groups, take one point each as the vertex to form a triangle. To maximize the total number of such triangles, how many points should each group have?
Solution: Let the number of points in the 30 groups be $n_{1}$, $n_{2}, \cdots, n_{30}$, where $n_{i}(i=1,2, \cdots, 30)$ are all distinct, then the total number of triangles satisfying the conditions is
$$
s=\sum_{1 \leqslant i < j < k \leqslant 30} \left\{
\begin{array}{l}
1, \text{ if } n_{i} + n_{j} > n_{k}, \\
0, \text{ otherwise.}
\end{array}
\right.
$$
$s$ increases if the difference between any two consecutive numbers is reduced.
Therefore, to maximize $s$, for any $1 \leqslant i \leqslant 29$, we have $n_{i+1}-n_{i} \leqslant 2$.
(2) In $n_{1}, n_{2}, \cdots, n_{30}$, if there are at least 2 values of $i$ such that $n_{i+1}-n_{i}=2$, without loss of generality, assume
$$
1 \leqslant i < j \leqslant 29, n_{i+1}-n_{i}=2, n_{j+1}-n_{j}=2.
$$

Similarly to (1), let $n_{i}^{\prime}=n_{i}+1, n_{j+1}^{\prime}=n_{j+1}-1$, and keep the number of points in the other groups unchanged, then $s$ increases.
Therefore, to maximize $s$, there is at most one $i$ such that $n_{i+1}-n_{i}=2$.
(3) If for any $1 \leqslant i \leqslant 29, n_{i+1}-n_{i}=1$, assume the number of points in these 30 groups are $m-14, m-13, \cdots, m+15$, then $30 m+15=2003$. This is impossible.

In summary, to maximize $s$, for any $1 \leqslant i \leqslant 29$, exactly one of $n_{i+1}-n_{i}$ is 2, and the rest are 1. Assume the number of points in these 30 groups are $m, m+1, \cdots, m+t-1, m+t+1, \cdots, m+30(1 \leqslant t \leqslant 29)$, then
$$
\begin{array}{l}
m+(m+1)+\cdots+(m+t-1)+ \\
\quad(m+t+1)+\cdots+(m+30) \\
=2003,
\end{array}
$$

which simplifies to $30 m+465-t=2003$.
Solving this, we get $m=52, t=22$.
Therefore, when the 30 groups have 52, 53, ..., 73, 75, ..., 82 points respectively, this distribution maximizes the total number of triangles.