시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
5 초 (추가 시간 없음) | 1024 MB | 25 | 17 | 16 | 69.565% |
It is a lovely summer day, and Alice wants to do a day trip. She lives in Tampere, and wants to travel to Porvoo to enjoy the Old Town and the surrounding nature. Alice does not only love travelling, but also planning.
She has created a map of the most beautiful paths to Porvoo. On her trip she needs to visit $n$ cities in order, where Tampere is the first city and Porvoo is the last city. The cities are connected by roads, with each road connecting two consecutive cities, and there is always at least one road between each pair of consecutive cities.
When driving from one city to the next, Alice needs to choose which road to take. Some of these roads have a tarmac surface, while others are just gravel roads and some roads have bridges which will not support vehicles that are too heavy. For each road it is known how long it takes to traverse it and what is the maximal weight of vehicles that can safely drive on it.
Figure E.1: Illustration of the second sample input. The red path from Tampere to Porvoo is the optimal choice for a car of weight $31$.
Alice collects many different cars of different weights, but she is not sure yet which car she will use for the day trip. As she wants to enjoy as much time in Porvoo as possible, she wants you to help her find the minimal travel time for each car.
The input consists of:
There is at least one connection from city $i$ to city $i+1$ for each $i$ ($1 \le i < n$).
Output $q$ lines, where the $i$th line describes the shortest time in minutes Alice needs to drive to get from Tampere to Porvoo with the $i$th car. If there is no feasible path for the $i$th car, output impossible
.
2 2 1 100 300 1 1 30 5 400 500 300 20 1
impossible impossible 100 1 1
5 7 1 200 30 2 200 31 3 200 32 4 200 33 1 5000 33 2 5000 33 3 5000 33 3 30 31 33
800 5600 15200
2 3 1 3 3 1 4 2 1 2 1 3 1 3 2
2 3 3
ICPC > Regionals > Europe > Northwestern European Regional Contest > German Collegiate Programming Contest > GCPC 2021 E번