T1
2025-07-28 08:51:47
发布于:浙江
10阅读
0回复
0点赞
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
vector<long long> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
long long operations = 0;
for (int i = 1; i < n; ++i) {
if (a[i] < a[i-1]) {
operations += a[i-1] - a[i];
a[i] = a[i-1];
}
}
cout << operations << endl;
return 0;
}
这里空空如也
有帮助,赞一个