문제
There are N desks in a room, placed from left to right, one next to each other. Some desks have phones on them, whereas some desks are empty. All phones are broken, so the phone on the i-th desk will ring if the phone at j-th desk rings, which is at most D desks away from the i-th desk. In other words, it holds | j - i | ≤ D. The first and the last desk will always have a phone on them. In the beginning the leftmost phone rings. What is the minimal amount of new phones to be placed on the desks so that the last phone rings?
입력
The first line of input contains two positive integers, N (1 ≤ N ≤ 300 000) and D (1 ≤ D ≤ N). The following line contains N numbers 0 or 1. If the i-th number is 1, then the i-th desk from the left has a phone on it, otherwise the i-th desk is empty.
출력
The first and only line of output must contain the required minimal number of phones.
채점
In test cases worth 40 points in total, it will hold 1 ≤ N ≤ 20.
예제 입력 1
4 1
1 0 1 1
예제 출력 1
1
예제 입력 2
5 2
1 0 0 0 1
예제 출력 2
1
예제 입력 3
8 2
1 1 0 0 1 0 0 1
예제 출력 3
2
코드를 제출하려면 로그인이 필요합니다.
로그인