You are given an integer array vulnerabilities of length n, where vulnerabilities[i] is the initial security score of server i.
You must perform exactly k operations. In each operation, choose any server i and decrease vulnerabilities[i] by 1.
After all k operations, let the resulting array be final.
Task: Compute the maximum possible value of min(final) that you can achieve by choosing which servers to decrement each time.
vulnerabilities
(length
n
)
k
(number of operations)
min(final)
1 ≤ n ≤ 2e5
0 ≤ vulnerabilities[i] ≤ 1e9
0 ≤ k ≤ 1e12
vulnerabilities = [5, 1, 4]
,
k = 3
5
three times →
[2, 1, 4]
, so
min = 1
.
1