cswork / OAOpen practice workspace

AmazonOA #133

Determine the Best Skipping Strategy

Estimated MediumJudge-ready

Topics (AI-labelled)GreedyBits & Math

In each warehouse you ship a items first, then your coworker ships b items; the coworker may skip, with at most skips skips in total. Turns alternate repeatedly until the stock is ≤0, and you earn 1 point only if you make the final shipment. Find the maximum score.

Input

The first line contains n a b skips, and the second line contains n stock values. The source has n≤100000 and positive stock; for the missing upper bounds this site sets stock, a and b to be positive and ≤10⁹, and 0≤skips≤10⁹.

Output

Output a single integer answer.

Example 1

Input:

6 2 3 3
10 6 12 8 15 1

Output:

5

Example 2

Input:

1 2 2 0
4

Output:

0

Example 3

Input:

1 2 2 1
4

Output:

1

Example notes

Example 1: the minimum skip costs of the six warehouses are 2, 0, 0, 1, 2, 0, so 3 skips earn 5 points. Example 2: you ship 2 first, then your coworker ships 2 and empties it, so you score nothing. Example 3: your coworker skips once, letting you ship 2 more and empty it, for 1 point.

Editorial

Loading solution…