#K55707. Equalize Array Elements
Equalize Array Elements
Equalize Array Elements
You are given an array (A) of (n) integers and an integer (k) representing the maximum number of operations allowed. In one operation, you can decrement an element by (1). Your goal is to determine whether it is possible to make all elements in the array equal using at most (k) operations.
The minimum number of operations needed to make all elements equal is given by the formula: [ \text{operations} = \sum_{i=1}^{n} (A_i - \min(A)) ] If (\text{operations} \leq k), output "YES"; otherwise, output "NO".
inputFormat
The first line contains two integers (n) and (k), where (n) is the number of elements in the array and (k) is the maximum allowed operations. The second line contains (n) space-separated integers representing the array (A).
outputFormat
Output a single line containing either "YES" if it is possible to make all elements equal using at most (k) operations, or "NO" otherwise.## sample
5 10
1 2 3 4 5
YES
</p>