Logo
(追記) (追記ここまで)

12110번 - Telefoni 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 64 MB132847365.179%

문제

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 ith desk will ring if the phone at jth desk rings, which is at most D desks away from the ith 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 ith number is 1, then the ith desk from the left has a phone on it, otherwise the ith desk is empty.

출력

The first and only line of output must contain the required minimal number of phones.

제한

예제 입력 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

힌트

In test cases worth 40 points in total, it will hold 1 ≤ N ≤ 20.

출처

Contest > Croatian Open Competition in Informatics > COCI 2016/2017 > Contest #6 2번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /