← All problemsSign in

There are n bulbs in a straight line, numbered from 0 to 1. Each bulb i has a button associated with it, and there is a cost,ci for pressing this button. When some button i is pressed, all the bulbs at a distance <=k from bulb i will be toggled(off->on, on->off). Given n,k, and the costs for each button, find and print the minimum cost of turning off all n bulbs if they're all on initially. ###

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