#include #include #include #include #include using namespace std; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ long n,k; cin >> n >> k; vector ws; for (long i=0;i> t; ws.push_back(t); } long a[n]; // best cost of turning off all bulbs below i for (long i=0;i::max(); for (long i=0;i 0) // there are unlit bulbs cost += a[lower-1]; // light up all bulbs up to lower // update each bulb affected by i for (long j=max(0L,lower); j<=upper; j++) a[j] = min(a[j],cost); } cout << a[n-1] << endl; return 0; }