IBMOA #33
Get Minimum Operations
Estimated MediumJudge-ready
Topics (AI-labelled)GreedyTwo Pointers
Each operation chooses exactly k consecutive positions and sets them all to 1. Find the minimum number of operations so that the string no longer contains m consecutive 0s. Existing 1s are unaffected.
Input
The first line contains n m k, and the second line contains the binary string. 1≤n≤200000, 1≤m,k≤n.
Output
Output one integer, the answer.
Example 1
Input:
6 3 2
000000
Output:
1
Example 2
Input:
3 1 1
111
Output:
0
Example 3
Input:
3 1 1
000
Output:
3
Example notes
The examples give 1, 0 and 3 respectively. In the first example, setting positions 3 to 4 to 1 gives 001100.
Editorial
Loading solution…