cswork / OA打开练习工作台

AmazonOA #133

Determine the Best Skipping Strategy

估计中等可在线判题

考点(AI 标注)贪心调度位运算

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.

输入格式

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 a single integer answer.

样例 1

输入:

6 2 3 3
10 6 12 8 15 1

输出:

5

样例 2

输入:

1 2 2 0
4

输出:

0

样例 3

输入:

1 2 2 1
4

输出:

1

样例说明

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.