Question: Solve it ASAP! I will upvote. Thanks, Java/CPP/Python any language you wish. Just make the logic clear. 4. Self-driving Express ByteDance is setting up a
Solve it ASAP! I will upvote. Thanks,
Java/CPP/Python any language you wish. Just make the logic clear.


4. Self-driving Express ByteDance is setting up a self-driving express vehicle base station for the e-commerce department We intend to set up a different number of base stations between different communities. The cost of self-driving vehicles per kilometer is $1.25. Assuming that there are a total of m communities and they are on a straight line. Bytebance has already known the location of each community Please calculate the minimum cost of setting up k base stations in the line. Example Input 5 5 12 Output 11.25 Output 11.25 Explanation In the example above k= 2, m = [18,2,5,12,3] Represents there are 5 communities located in 18km, 2km, 5m12km, 3km, and totally 2 base stations will be set up The best locations of base stations are 3km and 14km. Total cost would be (12-3| + |3-3 + 5-3] + |12-14| + 18-14]) = 9 * 1.25 = $11.25 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
