Editorial
If an arrangement realizes , transposing it realizes . It is therefore enough to construct nonnegative .
The column-maximum sum is maximized by making the maxima of the columns. If the row maxima in increasing order are , the first rows contain values, so necessarily . This yields the exact absolute bound
The row-major arrangement attains .
For , start from an arrangement with on the diagonal. Lower only the first-row maximum to and move the displaced large value elsewhere in the first column. This changes by exactly .
For larger , start from the maximum row-major construction. Keep the last row fixed so the column maxima stay fixed, and increase the maxima of the first rows from the bottom upward until their sum has increased by . The target maxima satisfy and remain strictly increasing, allowing the remaining smaller values to be distributed among the rows.
For negative , transpose the constructed matrix. The construction takes time. Solution written by GPT5.6