Exceeding Limits

시간 제한8초메모리 제한1024 MB

요약
길이와 제한속도가 있는 도로 그래프에서 1번에서 n번까지 최단 시간이 t 이하가 되도록 모든 제한속도에 더할 최소 속도 x를 구한다.
난이도

어려움10점 중 8점

유형
이분 탐색, 최단 경로, 그래프
정답자
아직 제출이 없습니다

문제

Tim needs to reach the Binary Analog Probing Conference (BAPC) on time, but he is running late. He is not sure if he can even make it on time without exceeding the speed limit! He does not like speeding, so he would like to minimize the amount that he needs to speed and plans his route accordingly. If he decides to speed by x km/hx\text{ km/h}, he will exceed the speed limit everywhere by exactly x km/hx\text{ km/h}.

Help Tim find the minimal amount that he needs to speed by to get to the BAPC in time.

As an example, consider the first sample case. Without speeding, Tim will take 40040+30020=25 hours\frac{400}{40} + \frac{300}{20} = 25\text{ hours} to drive from intersection 11, via intersection 33, to intersection 44. In order to arrive in time, he will need to exceed the speed limit by 10 km/h10\text{ km/h}, in which case his driving time will be 40040+10+30020+10=18 hours\frac{400}{40+10} + \frac{300}{20+10} = 18\text{ hours}, following the same route.

입력

The input consists of:

  • One line with three integers nn, mm, and tt (2≤n≤1042 \leq n \leq 10^4, 1≤m≤1051 \leq m \leq 10^5, 1≤t≤1051 \leq t \leq 10^5), the number of intersections, the number of roads, and the time within which Tim needs to reach his destination.
  • mm lines, each with four integers aa, bb, ℓ\ell, and vv (1≤a,b≤n1 \leq a, b \leq n, a≠ba \neq b, 1≤ℓ,v≤1051 \leq \ell, v \leq 10^5). Each line indicates a bidirectional road between intersections aa and bb with length ℓ\ell in km and speed limit vv in km/h.

The intersections are numbered between 11 and nn, inclusive.

Tim will start at intersection 11 and drive to intersection nn, which is guaranteed to be reachable.

출력

Output how much Tim needs to exceed the speed limit, in km/h. If Tim can reach his destination without speeding, output 00.

Your answer should have an absolute or relative error of at most 10−610^{-6}.

예제3

  1. 예제 1

    입력
    4 4 18
    1 2 800 40
    1 3 400 40
    4 2 500 50
    4 3 300 20
    
    예상 출력
    10
    
  2. 예제 2

    입력
    4 3 100
    1 2 300 15
    2 3 500 20
    3 4 300 30
    
    예상 출력
    0
    
  3. 예제 3

    입력
    4 4 10
    1 2 200 50
    2 3 300 30
    2 3 400 15
    3 4 500 50
    
    예상 출력
    56.9041576