← 返回 amazon 的题目列表Maximize Entries Meeting Need Within Given Capacity Allocation
类型:online_judge
amazon
Given two arrays answered and needed, and an integer capacity, write a function to allocate capacity in a way that maximizes the number of entries in needed that receive some capacity. Return this maximum number of entries.
Input
answered: An integer array representing the number of times already answered.
needed: An integer array representing the number of times needed.
capacity: An integer representing the total allocated capacity.
Output
Return the maximum number of entries in needed that can successfully receive capacity.
Example
answered = [2, 0, 5]
needed = [3, 2, 4]
capacity = 5
Output: 2
Constraints
Array lengths do not exceed 10^5.
Element values do not exceed 10^4.
The value of capacity does not exceed 10^6.
Example
Input
2
3
5