Hide

Problem B
Fair Prizes

/problems/fairprizes/file/statement/en/img-0001.png
Illustration of possible solutions to the first two sample cases. Note that in the second sample, although you have three claws available, you cannot place all three on the line of toys without overlapping them or sliding a claw past an edge.

The ground level of Wally’s Water Park has plenty of games for people who want a break from the slides, and they’re not even that rigged! One game in particular seems intriguing: there are $T$ toys placed in a row of $L$ slots, where each slot contains at most one toy. $C$ claws, each of length $W$, can take the toys present in $W$ contiguous slots from the line. Claws can slide along the line, but can’t slide partially off the edge or overlap each other (they can be immediately adjacent though). You can choose to not use all the claws, i.e., each claw is either fully on the line or not used at all.

The operator says that, included with the park’s admission, you can take as many toys as you are able to with the provided claws! How many toys can you take home?

Input

The first line of input consists of four integers $T$, $L$, $C$, and $W$ as described in the problem statement, such that $1 \leq C \leq T \leq L \leq 1000$ and $1 \leq W \leq L$.

The next line consists of $T$ distinct integers $1 \leq t_1 < t_2 < \dots < t_T \leq L$, indicating the slot position of each toy along the line.

Output

Output the maximum number of toys that you can take using the claws.

Sample Input 1 Sample Output 1
3 4 1 2
1 2 4
2
Sample Input 2 Sample Output 2
4 5 3 2
1 3 4 5
3
Sample Input 3 Sample Output 3
6 11 4 3
1 2 5 8 10 11
5
Sample Input 4 Sample Output 4
4 1000 2 6
3 8 20 25
4

Please log in to submit a solution to this problem

Log in