eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Hill Driving

Hill Driving

You're driving your car in the local hills and returning to your home town. You'd like to get back as quickly as possible; however, you notice that you don't have much fuel left. You know the most efficient route to take. Some parts of this route go downhill, and some go uphill. The different parts have different lengths and slopes. How quickly can you reach home with the little fuel you have left? We will assume a very simple model for the fuel consumption of your car. Fuel consumption (per unit distance travelled) will increase linearly with your driving speed v. However, there is an offset which depends on the slope s of the hill. For example, when going downhill along a particular road, you might be able to go at \textbf{10} km/h without expending any fuel; on the other hand, if you were travelling that same road uphill, you would expend fuel at the same rate as if you were driving \textbf{10} km/h faster along a flat road. More specifically, the car's fuel consumption \textbf{c} in liters per kilometer is given by \textbf{c = max(0, α v + β s)} where \textbf{α} is the standard fuel consumption rate on a flat road, \textbf{v} is your speed in km/h, \textbf{s} is the slope of the road, and \textbf{β} is a positive constant. Acceleration and deceleration do not cost fuel and can be done instantaneously. Note that your car has a maximum (safe) speed which cannot be exceeded. \InputFile On the first line a positive integer: the number of test cases, at most \textbf{100}. After that per test case: \begin{itemize} \item One line with four floating point numbers \textbf{α} (\textbf{0.1} ≤ \textbf{α} ≤ \textbf{100}), \textbf{β} (\textbf{0.1} ≤ \textbf{β} ≤ \textbf{100}), \textbf{vmax} (\textbf{10} ≤ \textbf{vmax} ≤ \textbf{200}) and \textbf{f} (\textbf{0} ≤ \textbf{f} ≤ \textbf{50}): the standard (flat road) fuel consumption rate of your car, the slope factor, the maximum speed of your car in km/h, and the amount of fuel you have left in liters, respectively. \item One line with an integer \textbf{r} (\textbf{1} ≤ \textbf{r} ≤ \textbf{10 000}): the number of road segments. \item \textbf{r} lines with two floating point numbers \textbf{x_i} and \textbf{y_i} (\textbf{1} ≤ \textbf{x_i} ≤ \textbf{1 000}, \textbf{-1 000} ≤ \textbf{y_i} ≤ \textbf{1 000}) each: the horizontal distance and height change (both in meters) of the \textbf{i}-th road segment. Each road segment has constant slope. \end{itemize} \OutputFile Per test case: \begin{itemize} \item One line with a floating point number: the fastest time in hours in which you can reach town. It is guaranteed that if it is possible to reach town at all, it will always be possible in less than \textbf{24} hours. If it is impossible to reach town, the line must contain "\textbf{IMPOSSIBLE}" instead. \end{itemize} Your output should have a relative or absolute error of at most \textbf{10^\{-6\}}.
Ліміт часу 1 секунда
Ліміт використання пам'яті 64 MiB
Вхідні дані #1
3 
10.0 1.0 150 0.0 
1 
100.0 -100.0 
10.0 100.0 150 1.0 
2 
100 0 
100 100 
0.5 0.1 100 10 
3 
1000 0 
100 10 
100 -10
Вихідні дані #1
1.414214
IMPOSSIBLE
0.072120
Джерело NWERC-2010