← 返回 amazon 的题目列表Maximize Minimal Element of Inventory
类型:online_judge
Given an integer array inventoryLevels, you can perform multiple operations such that you choose two elements, increase one by x units and decrease another by y units. Find the maximum possible value of the minimal element after operations.
Requirements:
Implement the function max_min_inventory(inventoryLevels, x, y).
Apply binary search to solve the problem.
Check if achieving the target value is possible.
Example:
Input: inventoryLevels = [3, 1, 4, 1, 5], x = 1, y = 1 Output: 4
Example
Input
[5, 2, 8, 4], 2, 1