BUCKETWA doubt

https://www.codechef.com/KOL18ROL/problems/BUCKETWA/

can anyone explain the concept of this problem.