#K93932. Longest Heatwave
Longest Heatwave
Longest Heatwave
You are given a list of daily temperatures and a threshold value. Your task is to determine the length of the longest heatwave, where a heatwave is defined as a consecutive sequence of days on which the temperature is strictly greater than the threshold.
More formally, given a sequence \(a_1, a_2, \dots, a_N\) and a threshold \(T\), find the maximum \(L\) such that there exists an index \(i\) with \(1 \le i \le N-L+1\) and \(a_i, a_{i+1}, \dots, a_{i+L-1}\) all satisfy \(a_j > T\) for \(j = i, i+1, \dots, i+L-1\). If no day has a temperature above \(T\), output 0.
inputFormat
The input is given via standard input (stdin) in the following format:
The first line contains two integers (N) and (T) where (N) is the number of days and (T) is the threshold temperature. The second line contains (N) space-separated integers representing the daily temperatures.
outputFormat
Output a single integer to standard output (stdout), which is the length of the longest heatwave (i.e., the longest consecutive sequence of days with temperatures greater than (T)).## sample
11 30
30 35 27 32 40 41 42 25 26 37 38
4