I have to find a cost optimal solution for staying on campsites.

It is kind of weigthed interval scheduling with a given number of intervals (nights).

I wonder how to tackle it, dynamic programmic will work for cost optimizatation gernerally but how to build in the restriction on the number of intervalls?