/
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 233 点
問題文
高橋君は気象観測が趣味で、毎日の最高気温を記録しています。彼は N 日間にわたって気温を記録しました。
i 日目(1 \leq i \leq N)に記録された最高気温は A_i ℃です。
高橋君は、連続する日の気温が厳密に増加している期間に注目しています。具体的には、1 \leq l かつ l + k - 1 \leq N を満たす整数 l, k について、l 日目から l+k-1 日目までの k 日間の気温が
A_l < A_{l+1} < \cdots < A_{l+k-1}
を満たすとき、この k 日間を長さ k の上昇期間と呼びます。k=1 のとき条件は自明に満たされるため、任意の 1 日は長さ 1 の上昇期間です。
高橋君は、記録した N 日間のデータの中で最も長い上昇期間の長さ(日数)を知りたいと思っています。その最大値を求めてください。
制約
- 1 \leq N \leq 2 \times 10^5
- -40 \leq A_i \leq 45
- 入力はすべて整数
入力
N A_1 A_2 \ldots A_N
- 1 行目には、記録した日数を表す整数 N が与えられる。
- 2 行目には、各日の最高気温を表す N 個の整数 A_1, A_2, \ldots, A_N がスペース区切りで与えられる。
出力
最も長い上昇期間の長さ(日数)を 1 行で出力せよ。
入力例 1
7 20 22 21 23 25 27 24
出力例 1
4
入力例 2
12 15 18 20 19 17 18 19 20 21 22 20 21
出力例 2
6
入力例 3
20 -5 -3 0 2 5 8 12 15 14 13 10 11 12 13 14 15 16 17 18 20
出力例 3
10
Score : 233 pts
Problem Statement
Takahashi has a hobby of weather observation and records the daily high temperature. He has recorded temperatures over N days.
The highest temperature recorded on day i (1 \leq i \leq N) is A_i ℃.
Takahashi is interested in periods where the temperatures on consecutive days are strictly increasing. Specifically, for integers l, k satisfying 1 \leq l and l + k - 1 \leq N, if the temperatures over the k days from day l to day l+k-1 satisfy
A_l < A_{l+1} < \cdots < A_{l+k-1}
then these k days are called a rising period of length k. When k=1, the condition is trivially satisfied, so any single day is a rising period of length 1.
Takahashi wants to know the length (in days) of the longest rising period in his N days of recorded data. Find this maximum value.
Constraints
- 1 \leq N \leq 2 \times 10^5
- -40 \leq A_i \leq 45
- All inputs are integers
Input
N A_1 A_2 \ldots A_N
- The first line contains an integer N representing the number of recorded days.
- The second line contains N integers A_1, A_2, \ldots, A_N separated by spaces, representing the highest temperature on each day.
Output
Print the length (in days) of the longest rising period in a single line.
Sample Input 1
7 20 22 21 23 25 27 24
Sample Output 1
4
Sample Input 2
12 15 18 20 19 17 18 19 20 21 22 20 21
Sample Output 2
6
Sample Input 3
20 -5 -3 0 2 5 8 12 15 14 13 10 11 12 13 14 15 16 17 18 20
Sample Output 3
10