Question: Hard ( 9 0 points ) : Least gas. You have n gas stations with integer locations given at miles a 0 , a 1

Hard (90 points): Least gas.
You have n gas stations with integer locations given at miles a0, a1,..., an1 on a straight road. It
requires $1 to travel 1 mile. Lets say we keep a house on this road with our car collection. Our
car collection also has n cars coincidentally. The 0th car in our collection travels to a0 The 1st car
travels to a1 and so on. Please find the minimum amount of money that must be spent to have
each of our cars travel to their respective destinations. Note that you must choose the optimal
location(s) of the house in particular to minimize this distance. It is guaranteed that both answers
are small enough to fit in the long long datatype in C. Fast solutions will get the 15 extra credit
points.
Please print out a valid location for the house, and the minimum amount of money that can be
spent (print both on separate lines).
Hint 1: What is the solution if there are 2 gas stations.
Hint 2: What is the solution if there are 3 gas stations. in progaming in c

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!