#t420. 滑雪
滑雪
Skiing
Problem Description
Michael likes to ski. That is not surprising — skiing is exciting. But to gain speed the slope must go downward, and once you reach the bottom you have to walk back up or wait for the ski lift to carry you. Michael wants to find the longest possible ski run in a region.
The region is given as a two-dimensional array; each number represents the height of that point. Here is an example:
1 2 3 4 5
16 17 18 19 6
15 24 25 20 7
14 23 22 21 8
13 12 11 10 9
A person may ski from a point to one of its four adjacent points (up, down, left, right) if and only if the height decreases. In the example above, a valid run is (starting at , ending at ). Of course is longer — in fact it is the longest.
Input Format
The first line contains and , the number of rows and columns of the region. The next lines each contain numbers giving the heights (two numbers are separated by a single space).
Output Format
A single integer: the length of the longest ski run.
Sample Input
5 5
1 2 3 4 5
16 17 18 19 6
15 24 25 20 7
14 23 22 21 8
13 12 11 10 9
Sample Output
25
Hint
For 100% of the test data, .