编程介的小学生 2019-12-31 01:31 采纳率: 20.5%
浏览 62

How Far Can Drive At Most 具体代码实现

Problem Description
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.

Input
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.)

Output
For each case, print the farthest I can drive, and output it with exactly two digits after the decimal point.

Sample Input
2
100 100
2
10 20 5
10 30 14
1000 10000
3
10 20 4
10 30 14
10 15 5

Sample Output
14.50
1000.00

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 MATLAB怎么通过柱坐标变换画开口是圆形的旋转抛物面?
    • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
    • ¥15 解riccati方程组
    • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
    • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
    • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
    • ¥50 树莓派安卓APK系统签名
    • ¥65 汇编语言除法溢出问题
    • ¥15 Visual Studio问题
    • ¥20 求一个html代码,有偿