#C11640. Longest Warm Period
Longest Warm Period
Longest Warm Period
You are given a sequence of daily average temperatures and an integer threshold. Your task is to determine the length of the longest continuous period during which the temperature was strictly greater than the threshold. More formally, given an array of temperatures \(T = [t_1, t_2, \dots, t_n]\) and an integer \(\text{threshold}\), you must compute the maximum length \(L\) such that for some consecutive segment \(T[i, i+L-1]\), every temperature satisfies \(t_j > \text{threshold}\) for \(i \le j \le i+L-1\). If no day has a temperature greater than the threshold, the answer is 0.
Note: A temperature is considered above the threshold only if temperature > threshold (i.e. strictly greater).
inputFormat
The input is read from standard input (stdin) and consists of two lines:
- The first line contains two integers \(n\) and \(threshold\), where \(n\) is the number of days.
- The second line contains \(n\) space-separated integers representing the daily temperatures.
outputFormat
Output a single integer to standard output (stdout) — the length of the longest consecutive period during which the temperature was strictly greater than \(threshold\).
## sample9 32
30 35 28 40 42 37 38 21 25
4