#K33267. Maximize the Minimum Value

    ID: 25050 Type: Default 1000ms 256MiB

Maximize the Minimum Value

Maximize the Minimum Value

You are given an array of n integers and a number k which represents the total number of increment operations you can perform on the array elements. In one operation, you can increment the value of any element by 1. Your task is to maximize the minimum value of the array after performing k operations optimally.

More formally, given an array \(a = [a_1,a_2,\ldots,a_n]\), you are allowed to add 1 to any element in the array at most \(k\) times (operations can be distributed arbitrarily among the elements). Determine the maximum possible value of \(\min(a)\) after these operations.

Input/Output Requirements:

  • Input: The first line contains two integers \(n\) and \(k\) separated by a space. The second line contains \(n\) space-separated integers representing the array \(a\).
  • Output: Print a single integer representing the maximum possible minimum value of the array after at most \(k\) increment operations.

The solution often involves using a greedy or binary search approach to efficiently determine the optimal minimum value achievable.

inputFormat

The first line contains two integers (n) and (k) separated by a space. The second line contains (n) integers representing the array (a).

outputFormat

Output a single integer: the maximum possible minimum value after performing at most (k) increment operations.## sample

3 5
1 2 3
3