The Hurdle Race

0

0 votes
Easy
Problem

Dan is playing a video game in which his character competes in a hurdle race. Hurdles are of varying heights, 
and Dan has a maximum height he can jump. There is a magic potion he can take that will increase his maximum 
height by  unit for each dose. How many doses of the potion must he take to be able to jump all of the hurdles.

Given an array of hurdle heights height, and an initial maximum height Dan can jump, k, determine the minimum
number of doses Dan must take to be able to clear all the hurdles in the race.

Input Format:

The first line contains two space-separated integers n and k, the number of hurdles and the maximum height Dan can jump naturally. 
The second line contains n space-separated integers height[i] where 0<=i<n.

Constraints:
1. 1<=n,k<=100
2. 1<=height[i]<=100

Output Format:

Print an integer denoting the minimum doses of magic potion Dan must drink to complete the hurdle race.

Sample input:
5 4
1 6 3 5 2

Sample output:
2

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?