← All problemsSign in

Cman and Candies

Cman doesn’t love bitwise operations anymore. He loves Alisha. Alisha is cute :). Cman know that most of all Alisha loves candies, that's why he bought N candies for her. Cost of ith candy is C[i]. Happiness associated with ith candy is defined as : A[i]=C[i] if i=1 A[i]=(Σ |C[i] - C[j]| for j = 1 to i - 1) % 10^9+7 if 2 Input - First line of input consists of a single integer T representing n

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