← 返回 microsoft 的题目列表Path With Maximum Minimum Value
类型:online_judge
Problem: Path With Maximum Minimum Value
Given an integer matrix grid of size m x n, start at the top-left cell (0,0) and move to the bottom-right cell (m-1,n-1). You may move one step at a time in 4 directions: up, down, left, right.
The score of a path is the minimum value among all cells on the path.
Return the maximum possible score among all valid paths from start to end.
Constraints
1 <= m, n <= 200
0 <= grid[i][j] <= 10^9
I/O Format (for this test)
Input:
First line: m n
Next m lines: n integers each
Output:
One integer: the maximum achievable path score
Test Cases
Case 1
Input:
3 3
5 4 5
1 2 6
7 4 6
Output:
4
Case 2
Input:
2 2
2 2
1 2
Output:
2
Case 3
Input:
3 4
8 7 6 5
1 2 3 4
9 9 9 1
Output:
1
Case 4
Input:
1 3
5 1 7
Output:
1
Case 5
Input:
3 1
5
4
3
Output:
3
Example
Input
3 3
5 4 5
1 2 6
7 4 6
Output
4