编程介的小学生 2017-06-01 06:23 采纳率: 20.5%
浏览 759
已采纳

Lode Runner

Problem Description
Lode Runner is a famous game, I think you played in your childhood.

Ok, now, I simple the problem. In the game, it has N horizontal roads, the ladders always stay at right side vertically, and the ladders are extending towards up and down with unlimited length. If ladder near or cross a road, little WisKey will walk on the road by climbed the ladder. Two roads were covered by each other in the X-axis; it will be considered can be passing through. Each road has an integer W means the dangerous level.

Little WisKey must start at No.1 road, and he can’t go back, he always go ahead. WisKey want to go some roads, so he needs to know how minimum sum of dangerous will happen. You can finish the game, yes?

Input
The first integer C represents the number of cases, And C cases followed.

Each test case contains a single integer N roads (1<=N<= 2000) and M destinations (1<=M<=500). The next N line contains three integers Si, Ei, Wi, meaning the road build from Si to Ei, and the Wi dangerous level (0 <= Si <= Ei <= 1000, 1 <= Wi <= 1000). And the roads sorted by Ei increasing yet. The last M line contains integers mean little WisKey’s destinations.

Output

For each questions, output the minimum sum of dangerous. If can’t reach the goal, please print -1.

Sample Input
3
10 4
1 4 7
5 6 3
3 7 5
2 9 8
10 13 8
12 14 11
11 15 13
16 18 5
17 19 6
8 20 9
1
2
3
10
5 5
1 4 5
3 6 10
5 8 20
2 9 1
7 10 2
1
2
3
4
5
4 4
1 5 1
2 7 20
2 7 3
7 9 4
1
2
3
4

Sample Output
7
-1
12
24
5
15
35
6
8
1
21
4
8

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-06-04 17:50
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!