← All problemsSign in

Sell All the Cars

Chef owns $N$ cars (numbered $1$ through $N$). He wishes to sell all of them over $N$ years by selling exactly one car per year. For each valid $i$, the initial price of the $i$-th car is $P_i$. Due to depreciation, the price of each car decreases by $1$ unit per year until it is sold. Note that the price of a car cannot drop below $0$ no matter how many years have passed, i.e. when the price o

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