Example 46 (4th CMO problem) 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. Question: To maximize the total number of triangles, how many points should each group have?

保留源文本的换行和格式，翻译结果如下：

Example 46 (4th CMO problem) 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. Question: To maximize the total number of triangles, how many points should each group have?
Analysis We will use the adjustment method to prove the number of points in each group, the smaller the difference, the greater the number of triangles, and thus find the required maximum value and the number of points in each group.

Solution Let the 30 groups be $M_{1}, M_{2}, \cdots, M_{30}$, and the number of points in each group be $m_{1}, m_{2}, \cdots, m_{30}\left(m_{1}0,
\end{aligned}
$

This contradicts the assumption that $S$ is maximized.
Next, we prove that when $S$ is maximized, there is only one $i$ such that $m_{i+1}-m_{i}=2$. In fact, if there exist $1 \leqslant i0$, which contradicts the assumption that $S$ is maximized.
Therefore, when $S$ is maximized, we can assume the number of points in each group to be
$$
m_{1}, m_{1}+1, \cdots, m_{1}+(k-1), m_{1}+(k+1), \cdots, m_{1}+30 .
$$

Thus, the total number of points in all groups is $30 m_{1}+\frac{1}{2} \times 30(30+1)-k=1989$,
which simplifies to $30 m_{1}-k=1524$.
Since $1524=30 \times 51-6$, we have $m_{1}=51, k=6$. Therefore, to maximize the number of triangles, the number of points in each group should be $\{51, 52, \cdots, 56,58,59, \cdots, 81\}$.