Aladdin and his Buckets
CodeChefOpen on judge ↗
Aladdin has $N$ different Buckets. Aladdin likes a number K. Aladdin wants to play a strange game. There are $A_i$ candies of type $i$. Initially, only the first bucket contains all the candies. **All the remaining $N - 1$ buckets are empty.** In order to do this, Aladdin will make some turns. Each turn he does the following: - He chooses any non-empty bucket and takes all of its candies (say
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start