Exceeding Limits
시간 제한8초메모리 제한1024 MB
길이와 제한속도가 있는 도로 그래프에서 1번에서 n번까지 최단 시간이 t 이하가 되도록 모든 제한속도에 더할 최소 속도 x를 구한다.
문제
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 , he will exceed the speed limit everywhere by exactly .
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 to drive from intersection , via intersection , to intersection . In order to arrive in time, he will need to exceed the speed limit by , in which case his driving time will be , following the same route.
입력
The input consists of:
- One line with three integers , , and (, , ), the number of intersections, the number of roads, and the time within which Tim needs to reach his destination.
- lines, each with four integers , , , and (, , ). Each line indicates a bidirectional road between intersections and with length in km and speed limit in km/h.
The intersections are numbered between and , inclusive.
Tim will start at intersection and drive to intersection , 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 .
Your answer should have an absolute or relative error of at most .