#include <iostream>
using namespace std;
int main()
{
int n,a,b;
long long int add;
while(cin>>n>>a)
{
add=0;
while(--n)
{
cin>>b;
if(a>b)
{
add+=a-b;
}
a=b;
}
cout<<add<<endl;
}
return 0;
}
<codeforces>Little Elephant and Sorting
小象排序挑战
最新推荐文章于 2022-05-30 01:20:02 发布
本文介绍了一个有趣的排序问题:如何使用最少的操作次数将整数数组变为非递减序列。通过简单的算法,文章提供了一种有效的方法来解决这个问题。
327

被折叠的 条评论
为什么被折叠?



