← All problemsSign in

Chef and Rods

Chef placed N rods on a straight line. The i-th rod is located at position xi and has length li. There are no two rods located at the same position. Chef can push rods to make them fall in any direction(left or right). A rod can touch its neighbors while falling and make them fall too in the similar direction $((x-h)$ to $(x+h))$.Chef wants to minimize the number of rods needed to push to make all

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