HIMARS
Limits: 3 sec., 256 MiB
This statement was translated automatically from Ukrainian.
In the BNR, there is a convoy of \(n\) Russian military objects. The convoy can be represented as a ray starting at the border of the BNR and Ukraine. Military object \(i\) is located at a distance \(a_i\) from the start of the convoy.
Zenik has two types of weaponry: Grad and HIMARS. Grad is able to destroy all Russian military objects on a single subsegment of the convoy of length \(x\) inclusive of its endpoints, and HIMARS — on a subsegment of length \(y\) inclusive of its endpoints. The number of Grad shells is unlimited, but HIMARS can only be fired \(k\) times.
What is the minimum number of shots required to destroy all Russian military objects?
Input
The first line contains 4 integers \(n\), \(k\), \(x\), and \(y\) — the number of Russian military objects, the number of available HIMARS shots, and the lengths of the segments covered by Grad and HIMARS, respectively.
The next line contains \(n\) integers \(a_i\) — the distances at which the military objects are located from the start of the convoy.
Output
Output a single number — the minimum number of shots required to destroy all Russian military objects.
Constraints
\(1 \le n \le 10^4\),
\(1 \le x, y \le 10^{9}\),
5 points:
\(1 \le k \le 10\),
\(1 \le a_i \le 1000\),
20 points:
\(1 \le k \le 2000\),
\(1 \le a_i \le 10^{9}\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 4 1 1 3 7 4 47 74 | 3 |
Notes
In the first test, you need to fire a HIMARS shot at the first two military objects simultaneously and use one Grad shot each for the third and fourth military objects.
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|