AmazonOA #161
Find Maximum Number of Subjects Passed (AS Intern, but it may apply to other interns)
估计简单可在线判题
Each subject already has answered[i] questions answered correctly, and passing requires at least needed[i]. You may answer at most q more questions correctly in total, distributed among the subjects in any way; maximize the number of subjects passed.
输入格式
The first line contains n q, the second line contains answered, and the third line contains needed. 1≤n≤100000; 0≤(each element),q≤10^9.
输出格式
Output a single integer answer.
样例 1
输入:
3 100
24 27 0
51 52 100
输出:
2
样例 2
输入:
2 1
2 4
4 5
输出:
1
样例 3
输入:
2 0
5 2
3 2
输出:
2
样例说明
Example 1: the first two subjects need 27+25=52 questions, so 2 subjects can be passed; all three subjects would need 152 questions, which exceeds the budget. Example 2: add 1 question to the second subject to pass 1 subject. Example 3: both subjects already meet the requirement, so no extra answers are needed and the answer is 2.