← 返回 amazon 的题目列表Minimum Sum of Prefix Differences
类型:online_judge
amazon
In this problem, you are given an integer array, and you need to perform some operations.
In each step, you can select an element of the array and move it to the left of its position. You can perform a limited number of operations.
Your goal is to make the sum of any prefixes of the array arranged in ascending order.
Return the number of operations necessary to make the prefix sums sorted.
Input Format:
An array of integers.
Output Format:
An integer representing the number of operations required.
Example:
Input: [3, 4, 5]
Output: 0
Input: [2, 1, 3]
Output: 1
Example
Input
1 2 3