Longest Stable Increasing


Submit solution

Points: 10
Time limit: 1.0s
Memory limit: 98M

Authors:
Problem type
Allowed languages
Java 19

最長穩定遞增區段(Longest Stable Increasing Segment)

Description

給定一個整數的一維陣列,請找出其中「最長的連續遞增區段」長度。

所謂連續遞增區段,定義如下: 從某一位置開始,後一個元素必須嚴格大於前一個元素, 直到遞增條件不再成立為止。

請輸出最長連續遞增區段的長度。 若所有元素皆無法形成遞增,則最長長度為 1。

Input

第一行輸入一個整數 n,表示陣列長度。
第二行輸入 n 個整數,表示陣列內容。

Output

輸出一個整數,表示最長連續遞增區段的長度。

Sample Input / Output

Sample Input Output directions
1 8 1 2 3 2 3 4 5 1 4 2 3 4 5連續遞增 4 個值
2 5 5 4 3 2 1 1 沒有連續遞增
3 6 1 2 3 4 5 6 6 1 2 3 4 5 6連續遞增 6 個值
4 7 1 1 1 1 1 1 1 1 沒有連續遞增

Comments

There are no comments at the moment.