ACdream的高速公路
Problem Description
ACdream王国有一条贯穿整个王国的高速公路,一天,你要驾驶着一辆油箱容量为P的车从高速公路的一头驶向另一头,总路程为L千米,每单位体积的汽油可维持行驶W千米,显然路途遥远~总有不够油的情况,所以就要加油~!
再高速公路上总共有N个加油站,但是由于是不同人开的,因此定价也参差不齐。
现在你知道每个加油站的位置,以及每个加油站的单价,问你最少需要多少钱才能到达另一头?
Input
多组数据,每组数据首先是四个整数,P(1<=P<=100),L(1<=L<=30000),W(1<=W<=20),N(1<=N<=500),分别代表油箱容量,路程,每单位体积的路程,加油站数目。
接下来是N行,每行包括一个精确到百分位的实数X(9<=Y<=L),分别表示每个加油站的单价以及每个加油站的位置。
Output
对于每组数据,如果能顺利抵达终点,则先输出一个"YES",然后输出最少花费。
否则输出一个"NO",再输出最远可以到达的位置。
字符串不包括双引号,注意大小写,输出数字只需要精确到百分之一即为正确。
Sample Input
50 1300 12 8 6.00 1250 7.00 600 7.00 150 7.10 0 7.20 200 7.50 400 7.30 1000 6.85 300 50 1300 12 2 7.10 0 7.00 600
Sample Output
YES 749.17 NO 1200.00
一辆车,行至一个城市,路途上有好多加油站,每个加油站价格不同,求行走过程中的最小钱数。首先把每个整数点都标记一个价格,遍历每一个加油站,对其所能到达范围遍历,然后对其进行更新价格。最后再遍历一次路程,若发现有地方无价格,则这就是最远距离,不能到达目的地。若都有价格,就把每单位价格相加,最后除以单位油行的路程。
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
}