HACKEREARTH QUESTION

How to solve this question?
https://www.hackerearth.com/codezilla-2016/algorithm/filling-buckets/
thanks!