← All problemsSign in

Bottled Water

Chef has _n_ bottles lined up in a row. Initialized th i-th bottle contains ai millilitres of water. Chef can pour water from one bottle to another in one operation. He will choose two bottles _a_ and _b_ (_a_ shouldn't be empty) and pour any possible amount of water (possibly, all water) from _a_ to _b_. The bottles have infinite capacity and can contain any amount of water. He can perform the

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