博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
To Fill or Not to Fill
阅读量:7122 次
发布时间:2019-06-28

本文共 1501 字,大约阅读时间需要 5 分钟。

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 price, and Di (<=D), the distance between this station and Hangzhou, for i=1,...N. All the numbers in a line are separated by a space.

Output Specification:

For each test case, print the cheapest price in a line, accurate up to 2 decimal places. It is assumed that the tank is empty at the beginning. If it is impossible to reach the destination, print "The maximum travel distance = X" where X is the maximum possible distance the car can run, accurate up to 2 decimal places.

Sample Input 1:
50 1300 12 86.00 12507.00 6007.00 1507.10 07.20 2007.50 4007.30 10006.85 300
Sample Output 1:
749.17
Sample Input 2:
50 1300 12 27.10 07.00 600
Sample Output 2:
The maximum travel distance = 1200.00

转载于:https://www.cnblogs.com/zjushuiping/archive/2012/06/04/2534308.html

你可能感兴趣的文章
玩转Go语言之Hello World!
查看>>
Redis 4.0 自动内存碎片整理(Active Defrag)源码分析
查看>>
优雅地乱玩Linux-2-zsh
查看>>
我从小程序学到了什么(一)
查看>>
学习笔记之事件循环-Event loop
查看>>
前端权限管理之 addRoutes 动态加载路由踩坑
查看>>
JavaScript算法之递归
查看>>
工厂方法与 FactoryBean(Spring对工厂模式的XML支持)
查看>>
div对角放置图片
查看>>
Spring Boot 自动配置原理
查看>>
每日一篇——lodash——array——chunk
查看>>
[译文] 如何在 Node.js 中使用 ES6 语法的 import/export
查看>>
js使用dispatchEvent派发自定义事件
查看>>
Java程序员从阿里、百度面试回来,这些面试题你们会吗?
查看>>
你知道我们平时在CSS中写的%都是相对于谁吗?
查看>>
如何使用 GitHub Flow 给开源项目贡献代码
查看>>
声明 NSString 类型的属性,到底用 strong 还是 copy ?
查看>>
gulp如何打包css、sass编译、自动加css前缀、js压缩、es6转换es5
查看>>
用python批量替换MD文件中的图片地址
查看>>
Linux vi/vim编辑器按键说明
查看>>