CF1066B Heaters
题目描述
## 题意描述:
$Vova$先生的家可以看作一个$n \times 1$的矩形,寒冷的冬天来了,$Vova$先生想让他的家里变得暖和起来。现在我们给你$Vova$先生家的平面图,其中$1$表示这个地方是加热炉,0表示这个地方什么也没有。所有加热器都有一个加热半径$r$,一个位于$a_i$加热器可以加热[$a_i-r+1,a_i+r-1$]的范围。现在,$Vova$先生想让他的整个家都变得暖和,一开始所有的加热器都是关闭的,请你求出$Vova$先生最少要开几个加热器才能使整个家变得暖和
输入格式
第一行:两个整数$n,r(1≤n,r≤1000)$,含义如上
第二行,n个整数,表示$Vova$家的地图
输出格式
一个整数,表示$Vova$先生至少要打开几个加热器
说明/提示
In the first example the heater at the position $ 2 $ warms up elements $ [1; 3] $ , the heater at the position $ 3 $ warms up elements $ [2, 4] $ and the heater at the position $ 6 $ warms up elements $ [5; 6] $ so the answer is $ 3 $ .
In the second example the heater at the position $ 1 $ warms up elements $ [1; 3] $ and the heater at the position $ 5 $ warms up elements $ [3; 5] $ so the answer is $ 2 $ .
In the third example there are no heaters so the answer is -1.
In the fourth example the heater at the position $ 3 $ warms up elements $ [1; 5] $ , the heater at the position $ 6 $ warms up elements $ [4; 8] $ and the heater at the position $ 10 $ warms up elements $ [8; 10] $ so the answer is $ 3 $ .