Marching Course
Time limit5sMemory limit512 MB
Find a closed walk from checkpoint 1 of at most P minutes that maximizes the sum of time times audience divided by road length.
- Level
Medium6 of 10
- Topics
- Graph, Shortest path, Dynamic programming
- Solved
- No attempts yet
Statement
Members of the Kitafuji High School Brass Band convinced their strict coach that they are ready to perform as a marching band at the Moon Light Festival. The festival is a warm-up for the upcoming domestic contest, so the band wants to draw a crowd with its performance.
The festival limits each performance to minutes. Each team may choose its route freely within the provided area. The area has checkpoints, numbered 1 through , and bidirectional roads, each connecting two checkpoints. The band knows the length and the expected number of people along every road. Each team must start at checkpoint 1 and return to checkpoint 1 within minutes.
If the band marches for minutes on a road with length and expected audience , the impression degree is . The impression degree of a course is the sum of the impression degrees of all its parts. The band marches at a constant speed of 1 length unit per minute. It may turn around at any time and at any place, including points in the middle of a road. An interval passed two or more times adds to the impression degree each time.
Find the course with the maximum impression degree for a -minute performance.
Input
The first line contains three integers , , and : the number of checkpoints (), the number of roads (), and the performance time (). Each of the following lines contains four integers , , , . Road connects checkpoints and (, ) with length () and expected audience (). Any two checkpoints are connected directly or indirectly. No two roads have the same pair of endpoints.
$N$ $M$ $P$
$s_1$ $t_1$ $d_1$ $v_1$
$\ldots$
$s_M$ $t_M$ $d_M$ $v_M$
Output
Print the maximum impression degree of a course for a -minute performance. Answers with an absolute error less than are accepted.