Go Back

Minimum Server Cost with Special Offer

Tiktok
Developer
Problem Description
You have buy servers to effectively manage their users, so you enter a shop to buy servers. Currently, the shop has n servers, where the price of the ith server is represented by the array element price[i]. The shop has a special offer for its customers: You can reduce the price of one server to the floor of half of its initial price. The total cost of servers is calculated as the sum of the absolute differences in the price of all adjacent servers. Given n servers and an array price[i], find‍‍‍‍‍‍‌‌‌‌‌‍‌‍‍‌‌‍‍ the minimum total cost required to buy all the servers from the shop, it is your choice to accept and apply the offer to any one of the servers. Example: Given n= 3, price =[1, 4, 1] answer is 2
Hints

No hints available for this question.