Tower
시간 제한2초메모리 제한1024 MB
막힌 계단 구간과 두 가지 이동 비용이 주어질 때, 0번 계단에서 각 질의 계단까지 오르는 최소 시간을 구하고 불가능하면 -1을 출력한다.
문제
The IOI Tower is an extremely tall tower equipped with a staircase for ascending. This staircase consists of steps, numbered sequentially from the bottom as step , step , and so on. JOI-kun is currently on step and intends to climb the staircase. JOI-kun can ascend the staircase by taking the following types of actions. Descending the staircase is not permitted.
- Ascend step. This action takes seconds.
- Jump from the current step to a step steps above, skipping the steps in between. This action takes seconds.
Currently, construction is ongoing at several locations on the staircase, and steps undergoing construction cannot be stepped on. Specifically, there are ongoing constructions, and the -th construction () is being carried out at steps .
The IOI Tower has rooms numbered from to . One can enter room () from step of the staircase. Therefore, JOI-kun has decided to determine whether he can reach each room and, if possible, how many seconds it will take to reach there in the minimum time.
Given the information about JOI-kun, constructions, and rooms, create a program that determines whether JOI-kun can reach step for each () and, if possible, calculates the minimum time it takes.
입력
Read the following data from the standard input.
출력
Output lines to the standard output. On the -th line (), output the minimum number of seconds it takes if JOI-kun can reach step ; otherwise, output -1.
제한
- .
- .
- .
- .
- .
- ().
- ().
- ().
- Given values are all integers.