#K70237. Minimum Operations to Increase Maximum Array Value

    ID: 33264 Type: Default 1000ms 256MiB

Minimum Operations to Increase Maximum Array Value

Minimum Operations to Increase Maximum Array Value

Given an integer array, the task is to compute the minimum number of operations required such that the maximum element of the array is increased by at least ( k ). In each operation, you may increment any single element of the array by 1. Notice that since only the maximum value influences the result, the answer is always simply ( k ).

For example, if the array is [1, 2, 3, 4, 5] and ( k = 3 ), then the new maximum must be at least ( 5 + 3 = 8 ). Thus, 3 operations are required.

inputFormat

The input is provided via standard input (stdin) in the following format:
1. An integer ( n ) representing the number of elements in the array.
2. ( n ) space-separated integers denoting the array elements.
3. An integer ( k ) representing the required increase over the original maximum value.

outputFormat

Output a single integer to standard output (stdout) representing the minimum number of operations needed such that the maximum value of the array becomes at least the original maximum plus ( k ).## sample

5
1 2 3 4 5
3
3