#T461. 滑雪

滑雪

Description

It's no surprise that Michael loves skiing, as skiing is indeed an exhilarating sport. However, to gain speed, the skiing area must slope downward, and once you reach the bottom of the slope, you have to either hike back up or wait for a ski lift to take you back. Michael wants to know the length of the longest possible ski path in a given area. The area is represented by a two-dimensional array where each number indicates the height of a point. Here's 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 can ski from a point to one of the four adjacent points (up, down, left, or right) if and only if the height decreases. In the example above, one possible ski path is 24-17-16-1. However, the path 25-24-23-...-3-2-1 is even longer. In fact, this is the longest possible path.

Input Format

The first line of input specifies the number of rows R and columns C (1 ≤ R, C ≤ 100) of the area. The following R lines each contain C integers representing the height h, where 0 ≤ h ≤ 10000.

Output Format

Output the length of the longest ski path.

```input1 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 ``` ```output1 25 ``` ```markdown ## Source

CodesOnline


The translation maintains the original markdown heading format (`##`) and the code block syntax. The content "CodesOnline" is kept as-is since it appears to be a proper name or brand that doesn't require translation. 

Note: If "CodesOnline" is intended to have a Chinese meaning (e.g., 代码在线), a more contextual translation might be provided, but based on the given input, it's treated as a name.