Train
시간 제한1초메모리 제한1024 MB
행성 간 기차 노선의 시간과 요금, 행성별 식사 비용이 주어질 때, 정해진 시간 구간 안에서 W끼의 식사를 하며 행성 N-1에 도착하는 최소 비용을 구한다.
문제
In the year 2992, most jobs have been taken by robots. Many people hence have abundant free time, and so is your family, who just decided to go for interstellar travel!
There are reachable planets indexed from to and interstellar train routes. The train route () starts from Planet at time , arrives in Planet at time , and costs . Trains are the only transportation between planets, so you can only get off a train on its destination planet, and must take the next train on the same planet (transfers take no time). Formally, a sequence of trains is valid to be taken if and only if for any , and .
As interstellar travel is time-consuming, you realize that in addition to the train fare, the cost of meals is significant. Thankfully, interstellar trains provide unlimited food for free. That is, if you decide to take train route , then at any time between and (inclusive) you can take any number of meals with no cost. But while your family is waiting for the next train on any Planet , you have to pay for each meal at the cost .
Your family need to have meals, and the -th () meal can be taken instantenously at any time between and (inclusive).
Now at time , your family are on Planet . You need to figure out the minimum cost to reach Planet . If you cannot reach there, your answer should be .
제한
- .
- .
- , .
- .
- .
- .
예제
이 문제는 공개된 예제가 없습니다.