6742.Mountain Range

Time Limit: 1s Memory Limit: 512MB

There are $n$ mountains in a row, each with a specific height. You begin your hang gliding route from some mountain.

You can glide from mountain $a$ to mountain $b$ if mountain $a$ is taller than mountain $b$ and all mountains between $a$ and $b$ .

What is the maximum number of mountains you can visit on your route?

Input Format(From the terminal/stdin)

The first line has an integer $n$ : the number of mountains.

The next line has $n$ integers $h_1, h_2,\dots, h_n$ : the heights of the mountains.

  • $1\le n \le 2 \cdot 10^5$
  • $1\le h_i \le 10^9$

Output Format(To the terminal/stdout)

Print one integer: the maximum number of mountains.

Sample Input

Copy
10
20 15 17 35 25 40 12 19 13 12
  \n
  ·  ·  ·  ·  ·  ·  ·  ·  ·  \n

Sample Output

Copy
5
 \n
Source: CSES, Dynamic Programming, 3314

Submit

请先 登录

© 2025 FAQs