当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

4132:How Far Can Drive At Most

题目描述
Now I am going to drive on a street. The street is a straight line. It will cost me one unit oil per meter. And my car can contain V units at most. Unfortunately some zones of the street have been damaged badly. The number of damaged zones is Q. One zone is represented as (l, r, C), means the zone between l to r is damaged, and it will cost me another C units of oil per peter. Please notice that zones may intersect. My question is how far can I drive at most.
输入解释
Several cases(cases <= 10). The first line is the case number T. Then T cases follow. For each case : First line two integers l (indicating the length of the street) and V (indicating the amount of oil my car can contain at most when I start)(1 <= len, V <= 10 ^ 9). Second line of each case is an integer Q (0 <= Q <= 50000). Then Q lines follow, each with three integers (l, r, C), means the zone between l to r has been damaged and it will cost me another C units of oil per meter(1 <= l < r <= len, 1 <= C <= 100). (If you still can not understand the details, please see the hint.)
输出解释
For each case, print the farthest I can drive, and output it with exactly two digits after the decimal point.
输入样例
2
100 100
2
10 20 5
10 30 14
1000 10000
3
10 20 4
10 30 14
10 15 5
输出样例
14.50
1000.00
提示
Hint:
In case 1, I can drive to 10 meters with total cost 10. Then as [10, 20] is covered by two zones, the cost of this zone if (1 +5 + 14) = 20 per meter.
So I candrive only 4.5 meters. And the answer is 14.50.
In case 2, I have so much oil that I can drive to the end of the road, and of course I can not drive farther. So the answer is 1000.00.
来自杭电HDUOJ的附加信息
Recommend lcy

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-4132

最后修改于 2020-10-25T23:10:34+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 32768/32768K(Java/Others)