#P4194. 矩阵

矩阵

Description

Given an integer matrix A[n×m]A[n\times m], find a matrix B[n×m]B[n\times m] such that 1in,1jm,Bi,j[L,R]\forall 1\le i\le n,1\le j\le m,B_{i,j}\in[L,R], and minimize the following value.

$$\max\begin{cases}\displaystyle\max_{1\le j\le m}\left\{\left|\sum_{i=1}^n\left(A_{i,j}-B_{i,j}\right)\right|\right\}\\\displaystyle\max_{1\le i\le n}\left\{\left|\sum_{j=1}^m\left(A_{i,j}-B_{i,j}\right)\right|\right\}\end{cases}$$

Input Format

The first line contains two integers nn and mm, the size of the matrix.

Each of the next nn lines contains mm integers, describing matrix AA.

The last line contains two integers LL and RR.

Output Format

Output one line with a single integer representing the answer.

2 2
0 1
2 1
0 1
1

Hint

Constraints: For 100% of the testdata, n,m200n, m \le 200, 0LR10000 \le L \le R \le 1000, 0Ai,j10000 \le A_{i,j} \le 1000.

Translated by ChatGPT 5