For the best experience, increase the window size or view on a laptop or desktop device
Title | ||
|---|---|---|
Loading... | ||
For the best experience, increase the window size or view on a laptop or desktop device
Title | ||
|---|---|---|
Loading... | ||
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
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
Output