Yesterday, at the ZOJ Monthly, there is a problem named Diagonal. Let us review that problem:
There is a N * N grids. Each grid should be filled with a number from 1, 2, .., N * N. No two girds share the same number...
But today, we have a new task, we should minimize the maximum sum of the any adjacent girds.
Output the answer for the above problem.
The optimal to fill the gird is:
1 4
3 2
the max sum of adjacent grid is 4+2=6
If you fill the grid:
1 3
2 4
the max sum of adjacent grid is 4+3=7
so the answer is 6.