#K63477. Magic Jumps: Maximization of Target Cell Value
Magic Jumps: Maximization of Target Cell Value
Magic Jumps: Maximization of Target Cell Value
Anton has a board represented by a matrix of dimensions \(n \times m\), where each cell contains an integer. He is allowed to perform an arbitrary number of magic jumps. In each magic jump, he can transfer the value from any cell (except for a designated target cell) to that target cell. The goal is to maximize the value of the target cell located at \( (t1, t2) \) (1-indexed).
Since Anton can eventually accumulate values from all cells except the target cell once, the maximum achievable value in the target cell is given by:
[ \text{Answer} = board[t1][t2] + \sum_{\substack{1 \leq i \leq n \ 1 \leq j \leq m,\ (i,j) \neq (t1,t2)}} board_{i,j} = \sum_{i=1}^{n} \sum_{j=1}^{m} board_{i,j} ]
Your task is to compute this value.
inputFormat
The first line of input contains two integers \(n\) and \(m\) representing the number of rows and columns of the board.
The next \(n\) lines each contain \(m\) space-separated integers which represent the board's cells.
The final line contains two integers \(t1\) and \(t2\) (1-indexed) specifying the target cell's position.
outputFormat
Output a single integer representing the maximum possible value in the target cell after performing the magic jumps (i.e. the sum of all the elements in the board).
## sample3 4
1 2 3 4
5 6 7 8
9 10 11 12
2 3
78
</p>