Question
Koko and the Banana Feast
Koko loves bananas. There are several banana bunches each kept one in a line. You are given the n number of bunches and the number of bananas in each bunch (one per line).
Koko can eat k bananas per hour.
If a bunch has more than k bananas, Koko continues eating it in the next hour until it’s finished.
Determine how many total hours Koko will take to finish all the banana bunches.
Koko can eat k bananas per hour.
If a bunch has more than k bananas, Koko continues eating it in the next hour until it’s finished.
Determine how many total hours Koko will take to finish all the banana bunches.
Input
1. The first line contains an integer n, the number of banana bunches.
2. The next line contains an integer k, the number of bananas Koko can eat per hour.
3. The next n lines each contain an integer, the number of bananas in that bunch.
2. The next line contains an integer k, the number of bananas Koko can eat per hour.
3. The next n lines each contain an integer, the number of bananas in that bunch.
Output
Print a single integer, total hours required to finish all bananas.
Example
Example 1:
Input:
3
3
7
9
4
Output:
8
Explanation:
Bunch 1 → 7 bananas → 3 hours (3 in 1st hour, 3 in 2nd hour, and 1 in 3rd hour)
Bunch 2 → 9 bananas → 3 hours (3 each hour)
Bunch 3 → 4 bananas → 2 hours (3 in 1st hour, 1 in 2nd hour)
Total = 3 + 3 + 2 = 8 hours
Input:
3
3
7
9
4
Output:
8
Explanation:
Bunch 1 → 7 bananas → 3 hours (3 in 1st hour, 3 in 2nd hour, and 1 in 3rd hour)
Bunch 2 → 9 bananas → 3 hours (3 each hour)
Bunch 3 → 4 bananas → 2 hours (3 in 1st hour, 1 in 2nd hour)
Total = 3 + 3 + 2 = 8 hours