#CCBOTPBA0000038. Dãy số theo ngưỡng hai trạng thái (Longest Consecutive Threshold Run)
Dãy số theo ngưỡng hai trạng thái (Longest Consecutive Threshold Run)
Longest Consecutive Threshold Run
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given n nonnegative numbers and threshold T, find the maximum length of a consecutive run of values at least T. A value below T resets the run.
Input
First n T, then exactly n nonnegative numbers.
Output
Print maximum qualifying run length.
Subtasks
-
Subtask 1 (20%):
n ≤ 20, values and threshold≤100. -
Subtask 2 (30%):
n ≤ 1000, values and threshold≤10^6. -
Subtask 3 (50%):
n ≤ 100000, values and threshold≤10^9.
Examples
Example 1
Input:
7 5
5 8 4 5 6 7 1
Output:
3
Explanation: The longest qualifying run is 5,6,7.
Example 2
Input:
3 9
0 1 8
Output:
0
Explanation: No item reaches the threshold.