Example 12 In space, there are 1989 points, where no three points are collinear. Divide them into 30 groups with different numbers of points. For any three different groups, take one point from each as the vertex to form a triangle. Question: To maximize the total number of such triangles, how many points should be in each group?
Solution: Divide 1989 points into 30 groups, with the number of points in each group denoted as $n_{1}, n_{2}, \cdots, n_{30}$. When taking one point from any three different groups to form a triangle, the total number of such triangles is $\sum_{1 \leqslant i<j<k \leqslant 30} n_{i} n_{j} n_{k}$. Since there are only a finite number of ways to divide the points, there must exist a division that maximizes the number of triangles formed.

If we modify the number of points in two groups while keeping the others unchanged, let the new number of points in each group be $n^{\prime}{ }_{1}, n^{\prime}{ }_{2}, \cdots, n^{\prime}{ }_{30}$, with $n^{\prime}{ }_{i}=n_{i}(i=3,4, \cdots, n)$. Since
\[
\sum_{1 \leqslant i<j<k \leqslant 30} n_{i} n_{j} n_{k}=\left(\sum_{k=3}^{30} n_{k}\right) n_{1} n_{2}+\left(\sum_{3 \leqslant j<k \leqslant 30} n_{j} n_{k}\right)\left(n_{1}+n_{2}\right)+ \sum_{3 \leqslant i<j<k \leqslant 30} n_{i} n_{j} n_{k},
\]
\[
\sum_{1 \leqslant i<j<k \leqslant 30} n_{i} n_{j} n_{k}=\left(\sum_{k=3}^{30} n^{\prime}{ }_{k}\right) n^{\prime}{ }_{1} n^{\prime}{ }_{2}+\left(\sum_{3 \leqslant j<k \leqslant 30} n^{\prime}{ }_{j} n^{\prime}{ }_{k}\right)\left(n^{\prime}{ }_{1}+n^{\prime}{ }_{2}\right)+ \sum_{3 \leqslant i<j<k \leqslant 30} n^{\prime}{ }_{i} n^{\prime}{ }_{j} n^{\prime}{ }_{k}=\left(\sum_{k=3}^{30} n_{k}\right) n^{\prime}{ }_{1} n^{\prime}{ }_{2}+\left(\sum_{3 \leqslant j<k \leqslant 30} n_{j} n_{k}\right)\left(n_{1}+n_{2}\right)+ \sum_{3 \leqslant i<j<k \leqslant 30} n_{i} n_{j} n_{k}.
\]
And $n_{1}+n_{2}=n^{\prime}{ }_{1}+n^{\prime}{ }_{2}$, therefore, if $\left|n^{\prime}{ }_{2}-n^{\prime}{ }_{1}\right|<\left|n_{2}-n_{1}\right|, n_{1} n_{2}=\frac{1}{4}\left[\left(n_{1}+n_{2}\right)^{2}-\left(n_{1}-n_{2}\right)^{2}\right],\left|n_{1}-n_{2}\right|$ the larger, the smaller $n_{1} n_{2}$. Thus, we can deduce that $\sum_{1 \leqslant i<j<k \leqslant 30} n_{i} n_{j} n_{k}<\sum_{1 \leqslant i<j<k \leqslant 30} n^{\prime}{ }_{i} n^{\prime}{ }_{j} n^{\prime}{ }_{k}$.

Now, assume that the number of points in each group is $n_{1}, n_{2}, \cdots, n_{30}$, and the total number of triangles formed is maximized. Since the number of points in each group must be different, we can assume $n_{1}<n_{2}<n_{3}<\cdots<n_{30}$. From the above, we can conclude that $n_{1}, \cdots, n_{30}$ must have the following properties:
(I) For any $k(1 \leqslant k \leqslant 29), n_{k+1}-n_{k} \leqslant 2$. If there exists some $k_{0}$ such that $n_{k_{0}+1}-n_{k_{0}} \geqslant 3$, then taking $n^{\prime}{ }_{k_{0}}=n_{k_{0}}+1, n_{k_{0}+1}^{\prime}=n_{k_{0}+1}-1\left(n^{\prime}{ }_{i}=n_{i}\right.$, when $\left.i \neq k_{0}, k_{0}+1\right)$, i.e., moving one point from the $(k_{0}+1)$-th group to the $k_{0}$-th group, will indeed increase the number of triangles.
(II) There is at most one $k$ such that $n_{k+1}-n_{k}=2$.
If there are two $i, j$ (let's assume $1 \leqslant i<j \leqslant 29$), such that $n_{i+1}-n_{i}=2$, $n_{j+1}-n_{j}=2$, then taking $n^{\prime}{ }_{j+1}=n_{j+1}-1, n^{\prime}{ }_{i}=n_{i}+1$ (the number of points in the other groups remains unchanged), will indeed increase the number of triangles. And $\sum_{k=1}^{30} n_{i}=1989$, therefore, it is impossible for $n_{k+1}-n_{k}=1(k=1,2, \cdots, 29)$, otherwise these 30 numbers would form an arithmetic sequence, and their sum should be a multiple of 15, but $15 \times 1989$). This implies that there must be some $k_{0}$ such that $n_{k_{0}+1}-n_{k_{0}}=2$, and these 30 numbers are $n_{1}, n_{1}+1, \cdots, n_{1}+k_{0}-1, n_{1}+k_{0}+1, \cdots, n_{1}+30$.

Thus, $1989+k_{0}=\frac{1}{2} \times 30\left(n_{1}+1+n_{1}+30\right)=15\left(2 n_{1}+31\right)$, solving for $k_{0}=6, n_{1}=51$.
Therefore, the number of points in each group is $51,52, \cdots, 56,57, \cdots 81$.