#K52897. Minimum Watering Operations

    ID: 29411 Type: Default 1000ms 256MiB

Minimum Watering Operations

Minimum Watering Operations

You are given n flowers with initial heights and a target height h. In one watering operation, all flowers are watered simultaneously, increasing their height by 1. Your task is to determine the minimum number of watering operations required to ensure that every flower reaches or exceeds the target height h.

Mathematically, if the initial heights are given by \(a_1, a_2, \dots, a_n\), then the minimum number of operations required is:

[ \max_{1 \le i \le n} (h - a_i) ]

Note that if a flower is already at or above the target height, it does not need additional water. However, since all flowers are watered simultaneously, the answer is determined by the flower that is the farthest from meeting the target.

inputFormat

The first line of the input contains two space-separated integers n and h, where n is the number of flowers and h is the target height.

The second line contains n space-separated integers representing the initial heights of the flowers.

outputFormat

Output a single integer on a new line, representing the minimum number of watering operations required for all flowers to reach or exceed height h.

## sample
5 10
3 6 2 8 4
8

</p>