Loading...
Loading...
A student writes a daily practice test for n days. A day counts as passed when that day's mark is at least p.
Find the length of the longest run of consecutive passed days. If no day was passed, print 0.
Example 1
Input
7 40 45 50 30 40 41 42 10
Output
3
Days 4, 5 and 6 (marks 40, 41, 42) form a streak of 3. A mark of exactly 40 counts.
Example 2
Input
3 90 10 20 30
Output
0
No day is passed.
Try the problem first. Open one hint at a time.
Keep a current streak length and a best length.
On a passed day, add 1 to current and update best. On a failed day, reset current to 0.
"At least p" means mark >= p, not mark > p.
Update best inside the loop, not only when a streak breaks, or a streak that reaches the last day is lost.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor