Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Binary search the answer.
To check if an answer is possible, for the ith hen check how far right it can go after ensuring that it eats the leftmost uneaten grain.
If the last grain is eaten in this process, the answer is possible.