#K77037. Minimum Days to Climb
Minimum Days to Climb
Minimum Days to Climb
John has N days available. On the i-th day, he can climb at most P[i] meters. He needs to climb at least H meters in total. Determine the minimum number of days required for John to reach or exceed this height.
If John is unable to reach the required height after using all of his given days, he can continue climbing additional days. In each extra day, he can climb at most \(\max(P)\) meters. The extra days needed can be computed using the formula:
\[ \text{extraDays} = \left\lceil \frac{H - \text{totalHeight}}{\max(P)} \right\rceil \]
Your task is to compute the minimum number of days required for John to reach at least H meters.
inputFormat
The input consists of two lines:
- The first line contains two integers N and H separated by a space, where N is the number of available days and H is the target height in meters.
- The second line contains N space-separated integers representing the list P, where P[i] is the maximum height in meters that John can climb on the i-th day.
outputFormat
Output a single integer representing the minimum number of days required for John to climb at least H meters.
## sample5 100
10 20 50 30 70
2
</p>