Dry Spells
Daily rainfall amounts are given. A dry spell is a maximal run of ≥ 3 consecutive zero-rain days. Count the dry spells.
Input: the first line has N; the second line has the N rainfall values.
Output: the number of dry spells.
Constraints:
- 1 ≤ N ≤ 105
- 0 ≤ rain ≤ 30
Sample Tests
Input 1
8 5 0 0 0 2 0 0 1
Output 1
1
Input 2
3 0 0 0
Output 2
1
Discussion (opens after you solve — no spoilers before)
No comments yet.