MicrosoftOA #54
Optimal Path in a Grid
估计简单可在线判题
Go from the first cell of the top row to the last cell of the bottom row, moving only right or down, and minimize the maximum number along the path.
This site uses a standard input/output protocol.
输入格式
The first line contains N, followed by two lines containing A and B respectively. This site uses 1≤N≤200000 and numbers in −10⁹..10⁹.
输出格式
Output a single integer, the answer.
样例 1
输入:
3
3 4 6
6 5 4
输出:
5
样例 2
输入:
6
1 2 1 1 1 4
1 1 1 3 1 1
输出:
2
样例 3
输入:
1
-3
-5
输出:
-3
样例说明
Example 1: move down at the middle column, passing 3, 4, 5, 4, for a maximum of 5. Example 2: move down to the right of the 3 in the bottom row, avoiding the 4 in the top row; the maximum is 2. Example 3: the path must pass through −3 and −5, so the maximum is −3.