Cream Bread
InterviewTime limit1sMemory limit1024 MB
Count the groups of K consecutive loaves where the number of loaves without cream (0) is fewer than P.
- Level
Easy2 of 10
- Topics
- Array, Implementation
- Solved
- No attempts yet
Problem
KOI Bakery sells bread filled with cream. The bakery made loaves in total. KOI Bakery sells the loaves in a row, grouping them at a time from the front. That makes groups in total.
In a hurry, some loaves were made without cream. If a group has or more loaves without cream, the group cannot be sold. In other words, a group can be sold only when it has fewer than loaves without cream.
You are given whether each loaf has cream. Find the number of groups that can be sold.
Input
The first line contains , , and , separated by single spaces.
The second line contains integers separated by spaces, one per loaf, in order from the front. A 0 means the loaf has no cream, and a 1 means it has cream.
Output
Print the number of groups that can be sold on the first line.
Constraints
- All given numbers are integers.