Under construction

Still being built. Things may change

Marching Course

Time limit5sMemory limit512 MB

Summary
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 PP minutes. Each team may choose its route freely within the provided area. The area has NN checkpoints, numbered 1 through NN, and MM 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 PP minutes.

If the band marches for mm minutes on a road with length dd and expected audience vv, the impression degree is m×v/dm \times v / d. 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 PP-minute performance.

Input

The first line contains three integers NN, MM, and PP: the number of checkpoints (2≤N≤2002 \le N \le 200), the number of roads (N−1≤M≤N(N−1)/2N-1 \le M \le N(N-1)/2), and the performance time (1≤P≤10001 \le P \le 1000). Each of the following MM lines contains four integers sis_i, tit_i, did_i, viv_i. Road ii connects checkpoints sis_i and tit_i (1≤si,ti≤N1 \le s_i, t_i \le N, si≠tis_i \ne t_i) with length did_i (1≤di≤10001 \le d_i \le 1000) and expected audience viv_i (1≤vi≤10001 \le v_i \le 1000). 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 PP-minute performance. Answers with an absolute error less than 10−410^{-4} are accepted.

Examples4

  1. Example 1

    Input
    3 3 4
    1 2 1 1
    2 3 2 4
    3 1 1 1
    
    Expected output
    6
    
  2. Example 2

    Input
    4 3 9
    1 2 2 1
    1 3 2 2
    1 4 2 3
    
    Expected output
    13.5
    
  3. Example 3

    Input
    4 3 5
    1 2 10 1
    2 3 2 100
    1 4 3 10
    
    Expected output
    16.6666666667
    
  4. Example 4

    Input
    3 3 10
    1 2 3 1
    1 3 4 5
    2 3 2 10
    
    Expected output
    22