GEMS
CodeChefOpen on judge ↗
Problem You have a sequence of N GEMS. Each gem has a value, represented by a number between 0 and 255, inclusive. The distance between two gems is the absolute difference of their numbers. You can perform each of the following operations zero or more times: - With cost R, remove any gem, so its original neighbors become neighboring gems. - With cost I, insert one gem of any value into any p
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