#BS0000427. Nỗi sợ nhện (Arachnophobia)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Nỗi sợ nhện (Arachnophobia)
Arachnophobia
Source: Kattis – https://open.kattis.com/problems/arachnophobia
Version: Phuoc Hung OJ Extended
Problem Statement
Anthony wants to reach a concert in ByteLand. There are intersections and bidirectional roads with positive integer lengths. He starts at , must reach within seconds, and travels at one meter per second.
Some intersections contain spiders. Define the distance between intersections as the shortest-path distance in the original road network. For a route, its safety value is the minimum distance from any intersection on that route (including both endpoints) to any spider intersection.
Find the maximum safety value among routes with total length at most .
Input
The first line contains . The next lines contain , describing a road of length between and . The next line contains . The final line contains followed by the spider intersections .
Output
Print the maximum possible integer .
Subtasks
Common conditions apply to all subtasks. Scoring groups are added by Phuoc Hung OJ.
; ; , ; ; .
The graph is connected and simple. A route from to of length at most always exists. All input values are integers.
Subtask 1 (20 points)
- , .
Subtask 2 (30 points)
- , .
Subtask 3 (50 points)
- , .
Examples
Example 1
Input
4 4 3000
0 1 1
1 3 1
2 0 2018
2 3 42
0 3
1 1
Output
1
Explanation
Route has length and safety . The start is only one meter from a spider, so no route can do better.
Example 2
Input
4 4 10
0 1 1
1 3 1
2 0 2018
2 3 42
0 3
1 1
Output
0
Explanation
The longer route exceeds the time limit. The feasible route passes through a spider intersection, giving .