#K36552. Longest Consecutive Hydrated Days
Longest Consecutive Hydrated Days
Longest Consecutive Hydrated Days
You are given an integer n, an integer goal (in milliliters), and a sequence of n integers representing daily water intake. Your task is to determine the length of the longest consecutive sequence of days during which the water intake was at least the goal.
Formally, if the water intake values are denoted by \(a_1, a_2, \dots, a_n\), you need to find the maximum length \(L\) such that there exists an index \(i\) where for all \(k\) with \(i \le k \le i+L-1\), the inequality \(a_k \geq \text{goal}\) holds. If no day meets the goal, output 0.
inputFormat
The first line contains two space-separated integers: n (the number of days) and goal (daily water intake target in milliliters). The second line contains n space-separated integers representing the water intake for each day.
outputFormat
Output a single integer representing the length of the longest consecutive sequence of days where the water intake meets or exceeds the goal.
## sample7 1500
1600 1800 1200 1500 2000 1300 1700
2