← All problemsSign in

Water buckets

CodeChefRating 3152Open on judge ↗

Chef has $N$ glasses of water numbered $1$ to $N$. The $i^{th}$ glass contains $A_i$ millilitres of water. Also, he has an unlimited supply of buckets, each having a capacity of $M$ millilitres. Consider the sequence of glasses $[B_1, B_2, \dots, B_k]$ ($B_j$ denotes the water volume in the $j^{th}$ glass) satisfying $1 \leq B_j \leq M$ for each $j$. We define the *bucket-cost* of this sequen

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.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start