This was essentially answered by Nate in the comments, but here are some more details. As Nate argues, $|m_i - m_j| \leq 1$ for all distinct $i,j$. Thus, if $s=ak+r$, where $a,r \in \mathbb{N}$ and $r < k$, then there is a unique choice (up to permuting variables) which maximizes the product. Namely, set $r$ of the variables to $\lceil s/k \rceil$ and the rest to $\lfloor s/k \rfloor$. This
This problem is related to Turán's Theorem, which concerns the maximum possible number of edges in a graph on $s$ vertices with no $K_{k+1}$ subgraph. The answer is given by the Turán graph, which is unique. More generally, Zykov proved that among $K_{k+1}$-free graphs, the Turán graph also has the most number of complete graphs $K_t$ for all $t \leq k$. The case $t=k$ leads to your optimization problem (once you have already established that such a graph must be $k$-partite).