AlgoLensArena
ContestlərProblemlərOtaqlar
Vizualizator
← Məsələlər

DAPC23-099.Exceeding Limits

Medium · 5 s · 256 MB

  • icpc
  • dapc
  • 2023

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}x km/h, he will exceed the speed limit everywhere by exactly x km/hx\text{~km/h}x 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}40400​+20300​=25 hours to drive from intersection 111, via intersection 333, to intersection 444. In order to arrive in time, he will need to exceed the speed limit by 10 km/h10\text{~km/h}10 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}40+10400​+20+10300​=18 hours, following the same route.

Giriş formatı

The input consists of:

• One line with three integers nnn, mmm, and ttt (2≤n≤1042 \leq n \leq 10^42≤n≤104, 1≤m≤1051 \leq m \leq 10^51≤m≤105, 1≤t≤1051 \leq t \leq 10^51≤t≤105), the number of intersections, the number of roads, and the time within which Tim needs to reach his destination.

• mmm lines, each with four integers aaa, bbb, ℓ\ellℓ, and vvv (1≤a,b≤n1 \leq a, b \leq n1≤a,b≤n, a≠ba \neq ba=b, 1≤ℓ,v≤1051 \leq \ell, v \leq 10^51≤ℓ,v≤105). Each line indicates a bidirectional road between intersections aaa and bbb with length ℓ\ellℓ in km and speed limit vvv in km/h.

The intersections are numbered between 111 and nnn, inclusive.

Tim will start at intersection 111 and drive to intersection nnn, which is guaranteed to be reachable.

Çıxış formatı

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

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

Qeyd

Source: Delft Algorithm Programming Contest 2023 · Author: Maarten Sijm · License: CC BY-SA 4.0 · Original: https://dapc.wisv.ch · Statement adapted for AlgoLens and shared under the same license. · 40 of the 142 original test cases (the largest) are omitted here to keep the problem lightweight.

Nümunələr

Giriş #1

4 4 18
1 2 800 40
1 3 400 40
4 2 500 50
4 3 300 20

Çıxış #1

10

Giriş #2

4 3 100
1 2 300 15
2 3 500 20
3 4 300 30

Çıxış #2

0

Giriş #3

4 4 10
1 2 200 50
2 3 300 30
2 3 400 15
3 4 500 50

Çıxış #3

56.9041576