Antique Street Lights

Time limit: 0.05s Memory limit: 32MB Input: Output:

George is very passionate about the good old times, so much that he switched the illumination in his street to old-fashioned oil lanterns.

The street is now nicely illuminated by a sequence of NN equally spaced lanterns, providing joy and delight to the whole neighbourhood.

However, he got the permission for doing so only by accepting to personally maintain the lanterns lit up: in fact, he has to ensure that given any subsequence
of consecutive MM lanterns, at least KK of them are lit up at any given time.

Tonight an heavy storm is coming down on George's neighbourhood, and some particularly strong wind gusts just extinguished part of the lanterns. George can see for each lantern ii whether it is lit (Li=1L_i = 1) or not (Li=0L_i = 0).

Since he doesn’t want to risk his concession to be revoked, it is time to get out in the storm and turn on some lights!

Task

Help George not to freeze in the storm, and find the minimum amount of lanterns which need to be lit up in order to comply with the city regulations!

Input data

The first line contains three integers NN, MM, KK.

The second line contains NN integers LiL_i, such that Li=0L_i = 0 if the corresponding lantern is off and Li=1L_i = 1 if it is on.

Output data

You need to write a single line with an integer: the minimum number of lanterns which need to be lit up.

Constraints and clarifications

  • 1KMN100 0001 \leq K \leq M \leq N \leq 100 \ 000
  • 0Li10 \leq L_i \leq 1 for each i=0N1i = 0 \dots N − 1
# Points Constraints
1 5 Examples.
2 10 K=MK = M
3 10 M=NM = N
4 20 N20N \leq 20
5 25 N1 000N \leq 1 \ 000
6 30 No additional constraints.

Example 1

stdin

5 2 1
0 1 0 0 1

stdout

1

Explanation

It is sufficient to lit up the lantern with i=2i = 2 obtaining the following configuration: 0 1 1 0 10 \ 1 \ 1 \ 0 \ 1.

Example 2

stdin

12 4 2
0 0 0 0 1 0 1 0 0 0 1 0

stdout

3

Explanation

It is sufficient to lit up the lanterns with i=2,3,8i = 2, 3, 8 obtaining the following configuration: 0 0 1 1 1 0 1 0 1 0 1 00 \ 0 \ 1 \ 1 \ 1 \ 0 \ 1 \ 0 \ 1 \ 0 \ 1 \ 0.

Log in or sign up to be able to send submissions!