Consider pairs $(f, g)$ of functions from the set of nonnegative integers to itself such that
- $f(0) \geq f(1) \geq f(2) \geq \cdots \geq f(300) \geq 0 ;$
- $f(0)+f(1)+f(2)+\cdots+f(300) \leq 300$;
- for any 20 nonnegative integers $n_{1}, n_{2}, \ldots, n_{20}$, not necessarily distinct, we have
$$
g\left(n_{1}+n_{2}+\cdots+n_{20}\right) \leq f\left(n_{1}\right)+f\left(n_{2}\right)+\cdots+f\left(n_{20}\right) \text {. }
$$

Determine the maximum possible value of $g(0)+g(1)+\cdots+g(6000)$ over all such pairs of functions.
Replace $300=\frac{24 \cdot 25}{2}$ with $\frac{s(s+1)}{2}$ where $s=24$, and 20 with $k$. The answer is $115440=$ $\frac{k s(k s+1)}{2}$. Equality is achieved at $f(n)=\max (s-n, 0)$ and $g(n)=\max (k s-n, 0)$. To prove
$$
g\left(n_{1}+\cdots+n_{k}\right) \leq f\left(n_{1}\right)+\cdots+f\left(n_{k}\right),
$$
write it as
$$
\max \left(x_{1}+\cdots+x_{k}, 0\right) \leq \max \left(x_{1}, 0\right)+\cdots+\max \left(x_{k}, 0\right)
$$
with $x_{i}=s-n_{i}$. This can be proven from the $k=2$ case and induction.
It remains to show the upper bound. For this problem, define a partition to be a nonincreasing function $p: \mathbb{Z}_{\geq 0} \rightarrow \mathbb{Z}_{\geq 0}$ such that $p(n)=0$ for some $n$. The sum of $p$ is defined to be $\sum_{n=0}^{\infty} p(n)$, which is finite under the previous assumption. Let $L=\mathbb{Z}_{\geq 0}^{2}$. The Young diagram of the partition is the set of points
$$
\mathcal{P}:=\{(x, y) \in L: yn \text {. }
$$

This is a partition with the same sum as $p$. Geometrically, the Young diagrams of $p$ and $p_{*}$ are reflections about $x=y$.
Since each $g(n)$ is independent, we may maximize each one separately for all $n$ and assume that
$$
g(n)=\min _{n_{1}+\cdots+n_{k}=n}\left(f\left(n_{1}\right)+\cdots+f\left(n_{k}\right)\right) .
$$

The conditions of the problem statement imply that $f\left(\frac{s(s+1)}{2}\right)=0$. Then, for any $n \leq k \frac{s(s+1)}{2}$, there exists an optimal combination $\left(n_{1}, \ldots, n_{k}\right)$ in $\left({ }^{*}\right)$ where all $n_{i}$ are at most $\frac{s(s+1)}{2}$, by replacing any term in an optimum greater than $\frac{s(s+1)}{2}$ by $\frac{s(s+1)}{2}$ and shifting the excess to smaller terms (because $f$ is nonincreasing). Therefore we may extend $f$ to a partition by letting $f(n)=0$ for $n>\frac{s(s+1)}{2}$ without affecting the relevant values of $g$. Then (*) implies that $g$ is a partition as well.

The problem can be restated as follows: $f$ is a partition with sum $\frac{s(s+1)}{2}$, and $g$ is a partition defined by $\left({ }^{*}\right)$. Find the maximum possible sum of $g$. The key claim is that the problem is the same under conjugation.
Claim - Under these conditions, we have
$$
g_{*}(n)=\min _{n_{1}+\cdots+n_{k}=n}\left(f_{*}\left(n_{1}\right)+\cdots+f_{*}\left(n_{k}\right)\right) .
$$

Proof. Let $\mathcal{F}$ and $\mathcal{G}$ be the Young diagrams of $f$ and $g$ respectively, and $\overline{\mathcal{F}}=L \backslash \mathcal{F}$ and $\overline{\mathcal{G}}=L \backslash \mathcal{G}$ be their complements. The lower boundary of $\overline{\mathcal{F}}$ is formed by the points $(n, f(n))$ for $i \in \mathbb{Z}_{\geq 0}$. By the definition of $g$, the lower boundary of $\overline{\mathcal{G}}$ consists of points $(n, g(n))$ which are formed by adding $k$ points of $\overline{\mathcal{F}}$. This means
where + denotes set addition. This definition remains invariant under reflection about $x=y$, which swaps $f$ and $g$ with their conjugates.

Let $A$ be the sum of $g$. We now derive different bounds on $A$. First, by Hermite's identity
$$
n=\sum_{i=0}^{k-1}\left\lfloor\frac{n+i}{k}\right\rfloor
$$
we have
$$
\begin{aligned}
A & =\sum_{n=0}^{\infty} g(n) \\
& \leq \sum_{n=0}^{\infty} \sum_{i=0}^{k-1} f\left(\left\lfloor\frac{n+i}{k}\right\rfloor\right) \\
& =k^{2} \sum_{n=0}^{\infty} f(n)-\frac{k(k-1)}{2} f(0) \\
& =k^{2} \frac{s(s+1)}{2}-\frac{k(k-1)}{2} f(0) .
\end{aligned}
$$

By the claim, we also get the second bound $A \leq k^{2} \frac{s(s+1)}{2}-\frac{k(k-1)}{2} f_{*}(0)$.
For the third bound, note that $f\left(f_{*}(0)\right)=0$ and thus $g\left(k f_{*}(0)\right)=0$. Moreover,
$$
g\left(q f_{*}(0)+r\right) \leq q \cdot f\left(f_{*}(0)\right)+(k-q-1) f(0)+f(r)=(k-q-1) f(0)+f(r),
$$
so we have
$$
\begin{aligned}
A & =\sum_{\substack{0 \leq q<k \\
0 \leq r<f_{*}(0)}} g\left(q f_{*}(0)+r\right) \\
& \leq \frac{k(k-1)}{2} f_{*}(0) f(0)+k \sum_{0 \leq r<f_{*}(0)} f(r) \\
& =\frac{k(k-1)}{2} f_{*}(0) f(0)+k \frac{s(s+1)}{2} .
\end{aligned}
$$

Now we have three cases:
- If $f(0) \geq s$ then
$$
A \leq k^{2} \frac{s(s+1)}{2}-\frac{k(k-1)}{2} f(0) \leq \frac{k s(k s+1)}{2} .
$$
- If $f_{*}(0) \geq s$ then
$$
A \leq k^{2} \frac{s(s+1)}{2}-\frac{k(k-1)}{2} f_{*}(0) \leq \frac{k s(k s+1)}{2} .
$$
- Otherwise, $f(0) f_{*}(0) \leq s^{2}$ and
$$
A \leq \frac{k(k-1)}{2} f_{*}(0) f(0)+k \frac{s(s+1)}{2} \leq \frac{k s(k s+1)}{2} \text {. }
$$

In all cases, $A \leq \frac{k s(k s+1)}{2}$, as desired.
Remark. One can estimate the answer to be around $k^{2} \frac{s(s+1)}{2}$ by observing the set addition operation "dilates" $\mathcal{F}$ by a factor of $k$, but significant care is needed to sharpen the bound.