7. For a finite non-empty set of real numbers $X$, denote the number of elements in $X$ as $|X|$, then
$$
f(X)=\frac{1}{|X|} \sum_{a \in X} a .
$$

The pair of sets $(A, B)$ satisfies
$$
A \cup B=\{1,2, \cdots, 100\}, A \cap B=\varnothing \text {, }
$$

and $1 \leqslant|A| \leqslant 98$.
For any $p \in B$, let
$$
A_{p}=A \cup\{p\}, B_{p}=\{x \mid x \in B, x \neq p\} \text {. }
$$

For all pairs of sets $(A, B)$ and $p \in B$ that satisfy the above conditions, find the maximum value of $\left(f\left(A_{p}\right)-f(A)\right)\left(f\left(B_{p}\right)-f(B)\right)$.
7. Let $S=\left(f\left(A_{p}\right)-f(A)\right)\left(f\left(B_{p}\right)-f(B)\right)$.

From the definition of $f$ and the conditions given in the problem, we have
$$
\begin{array}{l}
(|A|+1) f\left(A_{p}\right)=|A| f(A)+p, \\
(|B|-1) f\left(B_{p}\right)=|B| f(B)-p . \\
\text { Then } S=\left(\frac{|A| f(A)+p}{|A|+1}-f(A)\right) . \\
\left(\frac{|B| f(B)-p}{|B|-1}-f(B)\right) \\
=\frac{(p-f(A))(f(B)-p)}{(|A|+1)(|B|-1)},
\end{array}
$$

and $S=\left[f\left(A_{p}\right)-\frac{(|A|+1) f\left(A_{p}\right)-p}{|A|}\right]$.
$$
\begin{aligned}
& {\left[f\left(B_{p}\right)-\frac{(|B|-1) f\left(B_{p}\right)+p}{|B|}\right] } \\
= & \frac{\left(p-f\left(A_{p}\right)\right)\left(f\left(B_{p}\right)-p\right)}{|A||B|} .
\end{aligned}
$$

Next, we prove:
$$
|f(A)-f(B)| \leqslant 50,\left|f\left(A_{p}\right)-f\left(B_{p}\right)\right| \leqslant 50,
$$

and $S \leqslant \frac{625}{196}$.
In fact, note that $|A|+|B|=100$.
Thus, $f(A)-f(B)$
$$
\begin{array}{l}
\leqslant \frac{100+99+\cdots+(|B|+1)}{|A|}-\frac{1+2+\cdots+|B|}{|B|} \\
=\frac{100+(|B|+1)}{2}-\frac{1+|B|}{2}=50, \\
f(A)-f(B) \\
\geqslant \frac{1+2+\cdots+|A|}{|A|}-\frac{100+99+\cdots+(|A|+1)}{|B|} \\
=\frac{1+|A|}{2}-\frac{100+(|A|+1)}{2}=-50 .
\end{array}
$$

Therefore, $|f(A)-f(B)| \leqslant 50$.
Similarly, from $\left|A_{p}\right|+\left|B_{p}\right|=100$, we get
$$
\left|f\left(A_{p}\right)-f\left(B_{p}\right)\right| \leqslant 50 \text {. }
$$

When $1 \leqslant|A| \leqslant 97$, by
$$
(p-f(A))(f(B)-p) \leqslant\left(\frac{f(B)-f(A)}{2}\right)^{2} \leqslant 625 \text {, }
$$

and $(|A|+1)(|B|-1) \geqslant 2 \times 98=196$, hence from equation (1) we know
$$
S=\frac{(p-f(A))(f(B)-p)}{(|A|+1)(|B|-1)} \leqslant \frac{625}{196} .
$$

When $|A|=98$, according to equation (2) we have
$$
\begin{array}{l}
S=\frac{\left(p-f\left(A_{p}\right)\right)\left(f\left(B_{p}\right)-p\right)}{98 \times 2} \\
\leqslant \frac{1}{196}\left(\frac{f\left(B_{p}\right)-f\left(A_{p}\right)}{2}\right)^{2} \leqslant \frac{625}{196} .
\end{array}
$$

On the other hand, in the case where $A=\{1\}, B=\{2,3, \cdots, 100\}$ and $p=26$, we can verify from equation (1) that
$$
S=\frac{(26-1)(51-26)}{2 \times 98}=\frac{625}{196} \text {. }
$$

Thus, the maximum value of $S$ is $\frac{625}{196}$.