Chocolate Eating
Time limit1sMemory limit128 MB
Schedule N chocolates, eaten in fixed order over D days, to maximize the smallest bedtime happiness, where happiness halves each night and rises by eaten values.
- Level
Medium7 of 10
- Topics
- Binary search, Greedy, Simulation, Implementation
- Solved
- No attempts yet
Problem
Bessie has received () chocolates, but she does not want to eat them too quickly. She wants to plan her chocolate-eating schedule for the next () days so as to maximize the minimum happiness level she experiences over those days.
Bessie's happiness level is an integer that starts at . Each night while she sleeps it halves, rounding down. When she eats chocolate , her happiness level increases by the integer (). If she eats one or more chocolates on a day, her happiness for that day is the happiness level after she has eaten them (her bedtime happiness). Bessie must eat the chocolates in the order she received them, and she may eat any number of chocolates (including zero) on a given day.
For example, consider chocolates whose happiness values are , to be eaten over days. One optimal plan gives the following daily happiness:
The smallest bedtime happiness here is , and no plan can make this minimum any larger, so the answer is .
Input
- Line 1: two space-separated integers and .
- Lines 2 to : line contains a single integer .
Output
- Print a single integer: the highest possible value of Bessie's minimum bedtime happiness over the days.