#BS0000251. Koko ăn chuối (Koko Eating Bananas)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Koko ăn chuối (Koko Eating Bananas)
Koko Eating Bananas
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
Koko has banana piles with bananas in pile . The guards return in hours. She chooses a fixed positive integer rate . Each hour she eats up to bananas from one unfinished pile. If fewer than remain, she finishes that pile and waits until the next hour to start another. Find the minimum rate to finish all piles within hours.
Input
The first line contains : the number of piles and the time available in hours.
The second line contains exactly integers , representing the banana counts.
Output
Print the minimum eating rate in bananas per hour.
Subtasks
- Subtask 1 (20 points): ; for every ; .
- Subtask 2 (30 points): ; for every ; ; .
- Subtask 3 (50 points): ; for every ; .
Examples
Input
4 8
3 6 7 11
Output
4
Explanation
Rate 4 requires 1, 2, 2 and 3 hours, totaling 8. Rate 3 requires 1, 2, 3 and 4 hours, totaling 10. Lower rates cannot reduce the time, so 4 is minimal.