|
||||||||||
Lode RunnerTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1034 Accepted Submission(s): 504 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
Sample Output
Source | ||||||||||
|