Choir essay

Mr. Whitacre is having a lot of fun assaying with his choir. However, it
is a bit late and he will have to go home sooner or later. Furthermore,
it is starting to snow and the streets are getting worse by the minute.
How much time can Mr. Whitacre enjoy before departing?

Let us model the city as an undirected graph with n vertices (street
crosses, numbered from 0) and m edges (streets). Mr. Whitacre is
currently at vertex 0, and he has to reach vertex n − 1 (home). The cost
to traverse each street i is a_(i)t + b_(i), where t denotes the time
when Mr. Whitacre starts traversing that street. For instance, if he
starts walking that street right now, the time to traverse it is just
b_(i). Mr. Whitacre must be at home at most at time T.

Input

Input is all integer numbers, and consists of several cases, each with
n, m and T, followed by the information of the m streets x_(i) y_(i)
a_(i) b_(i). Assume 2 ≤ n ≤ 10⁴, 0 ≤ m ≤ 5n, 1 ≤ T ≤ 10⁶, x_(i) ≠ y_(i),
that between two vertices there is no more than one edge, and that a_(i)
and b_(i) are between 0 and 1000.

Output

For every case, print the maximum choir assay time with three digits
after the decimal point. If it is impossible to reach home at time T,
print “impossible”. The input cases have no precision issues.

Problem information

Author: Damià Torres

Generation: 2026-01-25T12:16:00.174Z

© Jutge.org, 2006–2026.
https://jutge.org
