#FW0000100. Đi chung xe (Carpool)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Đi chung xe (Carpool)
Carpool
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
There are passengers waiting at intersections , sharing starting depot and destination . Use the minimum number of cars needed, each carrying at most five passengers. A car can choose its pickup order, then proceed to the destination, spending an additional minutes at each passenger pickup. All cars operate in parallel. Minimize the finishing time of the last car.
Input
First line , followed by bidirectional roads between vertices .
Output
Print minimum time for all passengers to arrive.
Subtasks
-
Subtask 1 (40 points): . All input-format and graph conditions above apply.
-
Subtask 2 (60 points): . All input-format and graph conditions above apply.
Examples
Input
1 2
0 1 3
1 2 4
Output
12
Explanation
One car picks up passenger 1: depot 0 to pickup 1 takes 3 minutes, pickup 1 to office 2 takes 4, plus 5 minutes overhead, totaling .