The postman is at the beginning of a long street, right in front of house number 1. The houses are even numbered on one side of the street and odd numbered on the other. House number 2n is directly across the street from house number 2n-1. Moving to the next or previous house on the same side of the street takes 1 unit of time, and crossing the street takes crossTime units of time.
The postman has a bag of letters with him and he wonders how much time it will take him to deliver them all. He doesn't care which house he will be in front of at the end of the route; he just wants to know how much time it will take to deliver the letters if he proceeds in the fastest way. The numbers of the houses he has to deliver letters to are given by houseNumbers. How much time will this take him?
|