Grass
Limits: 2 sec., 256 MiB
Marichka and Zenyk need to mow the lawn. The lawn consists of \(n\) parts. Grass grow on each part, the height of the \(i\)-th path is \(h_{i}\). Marichka can mow \(X\) consecutive parts. Zenyk can mow arbitrary parts, but their total height can’t exceed \(Y\). What is the maximum number of parts they can mow?
Input
The first line contains three integers \(n\), \(X\), \(Y\) – number of parts, number of consecutive parts that Marichka can mow, and total height of the grass Zenyk can mow.
The second line contains \(n\) integers \(h_{i}\) – height of the grass on part \(i\).
Output
Print the maximum number of parts, that Zenyk and Marichka can mow.
Constraints
\(2 \le n \le 3 \cdot 10^{5}\),
\(1 \le X \le n\),
\(1 \le Y \le 10^{9}\),
\(1 \le h_{i} \le 10^{9}\).
Samples
Input (stdin) | Output (stdout) |
---|---|
5 2 5 3 4 4 2 5 | 4 |
Input (stdin) | Output (stdout) |
---|---|
5 2 5 4 3 4 2 5 | 3 |
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 |
---|