Nilay and Sweets
CodeChefOpen on judge ↗
Nilay is hungry and he went to a sweet shop. He has given prices of three sweets , all of which he wants to eat. First, he can eat any one sweet at cost 0. Then, just after eating the i-th sweet, he can eat the j-th sweet at cost ∣Aj−Ai∣. Here, ∣x∣ denotes the absolute value of x. Find the minimum money nilay will require to eat all the sweets. ### Input Input is given from Standard Input 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.
Sign in to chat with the tutor and save your progress.
Sign in to start