【PAT 1033】 To Fill or Not to Fill 贪心算法&模拟

1033. To Fill or Not to Fill (25)

时间限制

10 ms

内存限制

32000 kB

代码长度限制

16000 B

判题程序

Standard

作者

ZHANG, Guochuan

With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to time. Different gas station may give different price. You are asked to carefully design the cheapest route to go.

Input Specification:

Each input file contains one test case. For each case, the first line contains 4 positive numbers: Cmax (<= 100), the maximum capacity of the tank; D (<=30000), the distance between Hangzhou and the destination city; Davg (<=20), the average distance per unit gas that the car can run; and N (<= 500), the total number of gas stations. Then N lines follow, each contains a pair of non-negative numbers: Pi, the unit gas pr

你可能感兴趣的:(贪心算法,算法)