← 返回 amazon 的题目列表Minimum Machines for Same Efficiency
类型:online_judge
An analyst in the logistics team of Amazon e-commerce was reviewing the efficiency metrics of the new automated stocking and retrieval machines. Given a sequence of n machines with individual stocking/retrieving capacity values as an integer array machineCapacity. The efficiency is evaluated by the sum of the absolute difference between consecutive machine capacities. Determine if it's possible to achieve the same sum by removing some machines from the sequence. If possible, return the minimum number of machines required to attain the same sum of absolute differences. Note that the number of machines must always be greater than 0. If achieving the same sum is impossible on removal, return n, the original number of machines.
Example
Input
5
1 2 2 1 1