It's only 9 AM, and already your day has been horrible. You overslept your alarm, your oatmeal got cold as you listened to the traffic report, and the water in your shower was frigid. To make matters worse, as you got onto the highway you saw a horrible traffic jam. To try to make your day better, you have to figure out the fastest way to get to your exit.
You have been given lanes, a int[] listing the speed (in feet per second) of cars traveling in each lane on the highway. You begin in lane 0, and your exit (located dist feet away) is also in lane 0. You are allowed to move into an adjacent lane only if you have been in your current lane for at least laneChange seconds; otherwise, you won't have sufficient time to make sure there's no accident! This also includes exiting; if you change lanes during your trip, you must return in lane 0 for at least laneChange seconds in order to safely exit the highway. If you do not change lanes during your trip, then you may exit the highway as soon as you reach your exit.
With this information, return the least amount of time required for you to reach your exit. See the examples for further clarification.
|