给定一个长度为 n 的整数数组 a,我们希望将其变为单调不降(即对于所有 1≤i<n,有 ai≤ai+1)。
可以执行的操作为:
问:最少需要执行多少次上述操作,才能使得数组单调不降?
小笨有一个长度为 n 的数组 a,但众所周知小笨只对单调不降的数组感兴趣,即:ai≤ai+1(1≤i≤n)
现在,小苯希望将 a 变成他感兴趣的数组,为此他可以做以下操作:
By signing up a CodeFun2000 universal account, you can submit code and join discussions in all online judging services provided by us.