#P9822. Prof. Pang's Global Journey
Prof. Pang's Global Journey
Prof. Pang's Global Journey
Prof. Pang, a world-famous traveler, wishes to visit every point on a segment. Given a segment \([0, n]\) and two travelers starting at positions \(p_1\) and \(p_2\) with speeds \(v_1\) and \(v_2\) respectively, determine the minimum possible time required so that every point on the segment is passed by at least one traveler.
The travelers can move anywhere within the segment \([0, n]\) and may change direction instantly. They cannot leave the segment. One traveler may cover the entire segment or the two travelers can work together by partitioning the segment at some point \(x\) where the left traveler covers \([0,x]\) and the right one covers \([x,n]\). To cover an interval \([a, b]\) with a traveler starting at position \(p\) and moving with speed \(v\), the required time is at least \[ \frac{(b-a)+\min(|p-a|,|p-b|)}{v} \] seconds.
inputFormat
A single line containing five space-separated numbers: n, p1, v1, p2, v2. Here, 0 (\le p1, p2 \le n) and v1, v2 are positive real numbers representing the speeds (units per second) of the two travelers.
outputFormat
Print the minimum possible time (in seconds) required to ensure that every point on the segment ([0, n]) is passed by at least one traveler. The answer should have an absolute error of at most 1e-6.
sample
10 2 1 8 1
12.000000