← 返回 amazon 的题目列表Maximize Minimum Inventory in Warehouses
类型:online_judge
Given the stock quantities of several warehouses, you can choose two different warehouses at a time, increase stock of one by x and decrease stock of another by y, with x ≤ y. The aim is to make the minimum stock of all warehouses as large as possible. During the process, it's permissible to have negative stocks temporarily, but ultimately all stocks must be positive.
Input:
n (1 <= n <= 1000): Number of warehouses
stocks (List[int]): Initial stock quantities of each warehouse
Output:
int: The maximum possible minimum stock
Example
Input:
4
3 1 6 4
Output:
3
Explanation
In the example, by adjusting stocks, you can ensure the minimum possible stock is 3.
Example
Input
4
3 1 6 4