Engage the Medical Workers
题号:NC205093
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述


The medical team from Bitland has arrived at their destination --- a city named Matrix which is suffering from COVID-19. Now they are going to distribute the manpower to the place in need properly.

The Matrix city has only horizontal and vertical roads, dividing the city into separated blocks. That is, you can consider the blocks in this city form a real matrix of rows and columns!

The COVID-19 is now spreading among the blocks, which has infected many innocent people. xyjj, the captain of the team, now needs to consider how may medical workers should be sent to each block. If we note the number of patients in the blocks of row and as , and the number of medical workers sent to that block as , the basic rule of the arrangement will be as follows:

  1. If , then ;
  2. If , then ;
  3. If , then .

Here means any different rows and means any different column.

Because the life expenses of the workers are covered by the local block, xyjj hopes that the maximum number of workers to be sent to each block to be minimum (That is, minimize the among all the blocks) , so there will be less financial pressure for that block.

xyjj is too busy to solve this problem, can you help him?

输入描述:

The first line contains an integer , indicating that Matrix city has  rows and  columns of blocks.

In the next  lines, each line has  numbers. The -th number in the -th line represents the number  --- the number of patients in the block of the -th row and -th column in the Matrix city.

输出描述:

A integer represents the minimum possible maximum number of workers required to be sent to one block.
示例1

输入

复制
2
1 3
3 2

输出

复制
2

说明

The new matrix is:
\begin{bmatrix}1&&2\\2&&1\end{bmatrix}
so the answer is 2.