Given an array $$$a$$$ of length $$$n$$$ and an array $$$b$$$ of length $$$m$$$, construct a grid of size $$$n \times m$$$, where the value in cell $$$(x,y)$$$ is denoted as $$$C[x,y]$$$ and calculated as $$$a_x + b_y$$$.
You start from $$$(1,1)$$$, and in each step, you choose a grid cell located at the bottom right to move to, until you reach $$$(n,m)$$$, aiming to maximize the sum of absolute differences between adjacent cells along the path.
Formally, your goal is to find a sequence $$$(x_1,y_1), (x_2,y_2), ..., (x_k,y_k)$$$ that satisfies the conditions
The first line contains two integers, $$$n, m\ (1\le n,m \le 10^5)$$$.
The second line contains $$$n$$$ integers, representing the array $$$a\ (1\le a_i\le 10^5)$$$.
The third line contains $$$m$$$ integers, representing the array $$$b\ (1\le b_i\le 10^5)$$$.
One line with an integer representing the answer.
4 41 3 3 18 10 8 5
11
4 25 7 8 1010 3
12
| Название |
|---|


