cswork / OA打开练习工作台

AmazonOA #59

Get Maximum Credits (Dispatch Strategy)

估计中等可在线判题

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

At each warehouse you subtract dispatch1 first, then your colleague subtracts dispatch2, alternating until the stock is ≤0; whoever dispatches last gets the reward. The colleague may skip their own turn, at most skips times in total across all warehouses. Find the maximum number of warehouses you can win.

输入格式

The first line contains n dispatch1 dispatch2 skips (1≤n≤100000, the others 1..10⁹); the second line contains n stock values (1..10⁹).

输出格式

Output a single integer answer.

样例 1

输入:

3 2 3 1
3 6 2

输出:

3

样例 2

输入:

1 2 3 1
2

输出:

1

样例 3

输入:

2 1 4 1
5 5

输出:

0

样例说明

Example 1: stocks 6 and 2 need no skips and you dispatch last at both; stock 3 can also be won with 1 skip, so you can actually win 3, and the source answer 2 overlooked the available skip. Example 2: the first turn empties it directly, winning 1. Example 3: each warehouse needs 4 skips and a budget of 1 is not enough, so the answer is 0.