Example 5 (1989 National High School Mathematics Winter Camp Question) In space, there are 1989 points, among which no three points are collinear. Divide them into 30 groups with different numbers of points. From any three different groups, take one point from each to form a triangle. To maximize the total number of such triangles, how many points should each group have?
Thought analysis: First, divide 1989 known points into 30 groups with numbers $n_{1}, n_{2}, \cdots, n_{30}$. The total number of triangles with vertices in three different groups can be expressed as $S = \sum_{1 \leq i < j < k \leq 30} n_{i} n_{j} n_{k}$. If there exist $1 \leq i < j \leq 29$ such that $n_{i+1} - n_{i} \geq 2$, then replacing $n_{1}, n_{2}$ with $n_{1}^{1} = n_{1} + 1, n_{2}^{1} = n_{2} - 1$ will increase $S$, leading to a contradiction.
(2) The value of $i$ for which $n_{i+1} - n_{i} = 2$ can be at most one. If there exist $1 \leq i_{0} < j_{0} \leq 29$ such that $n_{i_{0}+1} - n_{i_{0}} = 2$ and $n_{j_{0}+1} - n_{j_{0}} = 2$, then replacing $n_{i_{0}}, n_{j_{0}+1}$ with $n_{i_{0}}^{1} = n_{i_{0}} + 1, n_{j_{0}+1}^{1} = n_{j_{0}+1} - 1$ will increase $S$, which is impossible.
(3) If the number of points in 30 groups increases by 1 for each adjacent group, let the number of points in the 30 groups be $K-14, K-13, \cdots, K, K+1, \cdots, K+15$, then
$$
\begin{aligned}
(K-14) & +(K-13)+\cdots+K+(K+1)+ \\
\cdots+(K+15) & =30 K+15,
\end{aligned}
$$

In this case, the total number of points is a multiple of 5, which cannot be 1989. Therefore, in $n_{1} < n_{2} < \cdots < n_{30}$, the difference between adjacent numbers is exactly 2 for one pair and 1 for all others.
(4) Let $n_{j}=\left\{\begin{array}{l}m+j-1, j=1,2, \cdots, i_{0}, \\ m+j, j=i_{0}+1, \cdots, 30 .\end{array}\right.$
where $1 \leq i_{0} \leq 29$. Then we have
$$
\sum_{j=1}^{i}(m+j-1)+\sum_{y=i_{0}+1}^{30}(m+j)=1989,
$$
$30 m - i_{0} = 1524$, solving this gives $m=51, i_{0}=6$. Therefore, when $S$ reaches its maximum value, the number of points in the 30 groups are 51, $52, \cdots, 56, 58, 59, \cdots, 81$.