My 4WD SUV can drive anywhere. Around here I can drive cross-country at a constant speed that is exactly half of my road speed.
Given a section of one-way road that is a sequence of straight-line segments, I want to know
the fastest way to get from the start of the section to the end of the section. I can
leave and re-enter the road as often as I wish.
Create a method suvTime that is given a int[] roadX and a int[] roadY and that finds the quickest route,
returning the time required as a fraction of the time required if I had to stay on the road. So, for example, a
return of .75 means that by using my SUV capabilities I can get to my destination in 3/4 of the
time required if I had to follow the road.
The i-th elements of roadX and roadY give the coordinates of i-th point along
the road, where the first elements gives the start point and the last elements
give the end point.
|