#CCBOTPBA0000015. Đoạn dương liên tục dài nhất (Longest Positive Run)
Đoạn dương liên tục dài nhất (Longest Positive Run)
Longest Positive Run
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given n integers, a positive run is a contiguous segment of values strictly greater than zero. Print its maximum length; print zero for an empty sequence or no positive values.
Input
Integer n, then exactly n integers.
Output
The maximum length of a positive run.
Subtasks
-
Subtask 1 (20%):
n ≤ 20;|a_i| ≤ 1000000. -
Subtask 2 (30%):
n ≤ 1000;|a_i| ≤ 1000000. -
Subtask 3 (50%):
n ≤ 100000;|a_i| ≤ 1000000.
Examples
Example 1
Input:
7
1 2 -1 4 5 6 0
Output:
3
Explanation: The run 4,5,6 has length three, longer than the initial run.
Example 2
Input:
0
Output:
0
Explanation: An empty sequence has no positive run.