Time limit
2s
Memory limit
512 MB
Simo will eat food N times during the next T minutes. The time when each food is eaten is given as a_i.
If she drinks one cup of Gymnema sylvestre tea at time x, its effect lasts for D minutes. Therefore, the effect applies to every food eaten at a time satisfying x ≤ a_i < x + D.
Simo may drink at most K cups. Even if the effects of multiple cups overlap, the same food-eating event is counted only once. Choose when she drinks the tea to maximize the number of food-eating events covered by the effect.
The first line contains four positive integers T, N, D, and K. (1 ≤ T ≤ 10^9, 1 ≤ N ≤ 10^6, 1 ≤ D ≤ 10^9, 1 ≤ K ≤ 10)
The second line contains N positive integers a_1, a_2, ..., a_N, where a_i is the time when the corresponding food is eaten. (1 ≤ a_i ≤ T)
Print the maximum number of food-eating events that can be covered by choosing the tea-drinking times optimally.