AdvancedRating 1800
Fewest Fuel Stops
A car must drive t km and starts with f litres (1 litre per km). Stations along the road are 'position fuel'; stopping at one adds all its fuel. Print the fewest stops to reach the target, or -1.
Input
t, f and n; then n lines 'position fuel' with increasing positions below t.
Output
One integer.
Sample 1
Input
100 10 4 10 60 20 30 30 30 60 40
Output
2
Sample 2
Input
1 1 0
Output
0
Output appears here