cswork / OA打开练习工作台

AmazonOA #93

Quiz Subjects — findMaximumNum

估计简单可在线判题

考点(AI 标注)贪心调度原地数组

For subject i, answered[i] questions have already been answered, and passing requires at least needed[i]. You can answer at most q more questions, distributed freely; find the maximum number of subjects you can pass.

输入格式

The first line contains n q (1≤n≤100000, 0≤q≤10⁹), the second line contains answered, and the third line contains needed, all 0..10⁹.

输出格式

Output a single integer answer.

样例 1

输入:

3 100
24 27 0
51 52 100

输出:

2

样例 2

输入:

2 0
5 5
1 9

输出:

1

样例 3

输入:

2 5
0 0
2 3

输出:

2

样例说明

Example 1: adding 25 and 27 questions passes two subjects, and the remaining 48 is not enough for the third. Example 2: the first subject is already passed, so with a budget of 0 you still pass 1 subject. Example 3: adding 2 and 3 uses up the budget exactly, and two subjects pass.