← All problemsSign in

Circle Eating

CodeChefRating 2971Open on judge ↗

There are $N$ candies (numbered $1$ through $N$) on a circular table. For each valid $i$, candies $i$ and $i+1$ are adjacent; candies $1$ and $N$ are also adjacent. You want to eat all these candies. Initially, your *happiness level* is $0$. For each valid $i$, when you eat the $i$-th candy, the happiness level increases by $a_i$. Note that $a_i$ may be negative and your happiness level may als

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