title: Dynamic programming algorithm for truck on road and fuel stops problem
body: <p>A truck burns 1 unit of fuel while travelling 1 unit of distance. The truck has to reach town, which is located <strong>L</strong> units of distance along the road, and at the starting point the truck has <strong>P</strong> units of fuel in the tank (both values are <strong>given as (L,P)</strong> pair). The fuel tank is infinite, so the truck can always store more fuel. A number of possible fuel stops along the road is given as pairs of integers <strong>(a,b)</strong> where <strong>a</strong> is <strong>distance between the town and the fuel stop</strong>, and <strong>b</strong> is the number of fuel units that this fuel stop can provide.</p>
  
  <p>The goal is to make as few stops as possible on the way to town. The algorithm must return the smallest number of stops required to make the trip.</p>
  
  <p>I figured out how to solve this problem with a greedy algorithm, using a priority queue, but I'm struggling to find a dynamic approach to the problem. I know thet there is one, but I cannot figure it out. I'll appreciate any hints.</p>