← All problemsSign in

Candies

There is a candy shop that sells $N$ varieties of candies. The $i$-$th$ variety has $a_i$ candies. You want to buy as many candies as possible. If you buy $b_i$ candies of variety $i$, then for all $1 \leq j \lt i$ either $b_j = 0$ (you bought 0 candies of type $j$) or $b_j \lt b_i$ (you bought less candies of type $j$ than of type $i$). Remember, there is no shortage of money. *** ###Inpu

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