#K37112. Painting Fences

    ID: 25905 Type: Default 1000ms 256MiB

Painting Fences

Painting Fences

You are given n fences with varying heights. In one stroke, you can paint each fence up to a maximum height increment of k. The task is to determine the minimum number of strokes required to paint all the fences completely.

Mathematically, if the maximum fence height is \(H = \max\{h_1, h_2, \ldots, h_n\}\), the answer is given by \(\lceil \frac{H}{k} \rceil\), where \(\lceil x \rceil\) denotes the ceiling function (i.e. the smallest integer not less than \(x\)).

For instance, if you have 7 fences with heights from 1 to 7 and \(k = 3\), the answer would be 3 since \(\lceil 7/3 \rceil = 3\).

inputFormat

The input consists of two lines. The first line contains two integers n and k separated by a space, where n is the number of fences and k is the maximum height that can be painted in one stroke. The second line contains n space-separated integers representing the heights of the fences.

outputFormat

Output a single integer representing the minimum number of strokes required to paint all the fences.## sample

7 3
1 2 3 4 5 6 7
3