Maximizing the sum of hook lengths

Given positive integers $a\geq b$, and $n\in\{1,2,\dots,ab\}$ I am looking for a partition of $n$ into at most $b$ parts of size at most $a$ which maximizes the sum of the hook lengths in the corresponding Young diagramm. Intuitively, for $n=qa+r$ with $0\leq r\leq a-1$, I would choose $\lambda_1=\lambda_2=\dots=\lambda_q=a$ and $\lambda_{q+1}=r$ which gives a hook lengths sum of $$q\binom{a}{2}+a\binom{q}{2}+\binom{r}{2}+rq+n.$$ Is there a better construction, or a simple argument that this is optimal?

• Should be true or almost true. There is a simple argument why if you have a decreasing function $f$ from $[0,a]$ to $[0,b]$, then $\int_0^a f^2+\int_0^b(f^{-1})^2$ is maximized when $f$ is constant (the other one is a jump function then) and that is the limiting case of your problem, so the only situation I'm potentially afraid of is when $b=a-1\mid n$ and $r$ is something ridiculous like $a/2$, in which case the gain on flatness may be larger than the gain on using a longer side. Have you checked this situation?. – fedja Jun 13 '18 at 23:19
• Thanks @fedja. I'll check the extreme situation you mention. – Thomas Kalinowski Jun 14 '18 at 0:26
• Anyway, it is essentially the same problem as mathoverflow.net/questions/295705/…, so the article cited there should tell you the whole story (just think of the Young diagram filled with $1$'s as of an adjacency matrix of a bipartite graph on $a$ red and $b$ blue vertices). – fedja Jun 14 '18 at 0:58
• @fedja: Indeed, Lemma 2 in this paper is exactly what I need. Thanks a lot. – Thomas Kalinowski Jun 14 '18 at 1:31