CF1675G Sorting Pancakes
题目描述
### 题意简述
有 $n$ 个箱子和 $m$ 个小球,初始时第 $i$ 个箱子有 $a_i$ 个小球。每次操作可以将**一个**小球移到相邻的箱子里。求要使得最终数组 $a_i\ge a_{i+1}$ 的最小操作次数。
输入格式
第一行两个正整数 $n,m$。
第二行 $n$ 个非负整数 $a_i$。数据保证 $\sum a_i=m$。
输出格式
输出一行一个非负整数,表示答案。
### 数据规模
$1\le n,m\le 250$
说明/提示
In the first example, you first need to move the pancake from the dish $ 1 $ , after which $ a = [4, 4, 2, 3, 3, 3] $ . After that, you need to move the pancake from the dish $ 2 $ to the dish $ 3 $ and the array will become non-growing $ a = [4, 3, 3, 3, 3, 3] $ .