PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#FW0000020. Cuộc thi gặp mặt (A Contest to Meet)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Cuộc thi gặp mặt (A Contest to Meet)
A Contest to Meet
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Three contestants start at arbitrary intersections and must eventually meet at an arbitrary intersection, also not known in advance. Each walks along a shortest route at their own speed. Find the smallest integer broadcast duration that suffices for every possible combination of starting locations and meeting location. Early arrivals may wait.
Input
, followed by undirected lengths using zero-based vertices, then three speeds.
Output
Print the minimum sufficient integer number of minutes.
Subtasks
- Subtask 1 (40 points): ; ; ; ; ; ; the graph is connected.
- Subtask 2 (60 points): ; ; ; ; ; the graph is connected.
Examples
Input
2 1
0 1 150
60 50 75
Output
3
Explanation
The diameter is meters and the slowest contestant walks at meters/minute, so the worst-case travel time is minutes.