#abc185d. [abc185_d]Stamp
[abc185_d]Stamp
Problem Statement
There are squares arranged in a row from left to right. Let Square be the -th square from the left.
of those squares, Square , , , , , are blue; the others are white. ( may be , in which case there is no blue square.)
You will choose a positive integer just once and make a stamp with width . In one use of a stamp with width , you can choose consecutive squares from the squares and repaint them red, as long as those squares do not contain a blue square.
At least how many uses of the stamp are needed to have no white square, with the optimal choice of and the usage of the stamp?
Constraints
- are pairwise distinct.
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
$A_1 \\hspace{7pt} A_2 \\hspace{7pt} A_3 \\hspace{5pt} \\dots \\hspace{5pt} A_M$
Output
Print the minimum number of uses of the stamp needed to have no white square.
Sample Input 1
5 2
1 3
Sample Output 1
3
If we choose and repaint the three white squares one at a time, three uses are enough, which is optimal.
Choosing or greater would make it impossible to repaint Square , because of the restriction that does not allow the squares to contain a blue square.
Sample Input 2
13 3
13 3 9
Sample Output 2
6
One optimal strategy is choosing and using the stamp as follows:
- Repaint Squares red.
- Repaint Squares red.
- Repaint Squares red.
- Repaint Squares red.
- Repaint Squares red.
- Repaint Squares red.
Note that, although the consecutive squares chosen when using the stamp cannot contain blue squares, they can contain already red squares.
Sample Input 3
5 5
5 2 1 4 3
Sample Output 3
0
If there is no white square from the beginning, we do not have to use the stamp at all.
Sample Input 4
1 0
Sample Output 4
1
may be .