You have an array of size n
of positive integers on which you can do the following operation by at most N
times:
k
(k
must be smaller than the sub-array's minimum value). k
. M
. N
and M can be extremely large. Can you give me an efficient algorithm for minimizing the maximum element in this array?
Suppose we chose x as the maximal number in the reduced array we can take the array and decrease all its larger elements to x and calculate the cost of these operations and their number then we can try joining greedily the cheapest(in cost) subsets of these elements until the number of operations is smaller than N.If cost becomes larger than M then the maximal element must be larger in the reduced array.As for x we can easily binary search it.