← All problemsSign in

Chocolates

You have $N$ students and you want to give chocolates to them and previously they have some chocolates. You want to have them exactly same number of chocolates in given list. In one command you can choose $L$ and $R$ and increase or decrease 1 chocolate from each student between $L$ and $R$ where $1$ <= $L$ <= $R$ <= $N$. Find minimum number of commands required. ### Input -The first line of in

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