#include <iostream>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
int n, m;
LL a[N];
int main()
{
cin >> n >> m;
LL cnt = 0;
cin >> a[1];
if (a[1] > m) cnt += a[1] - m, a[1] = m;
for (int i = 2; i <= n; i ++ )
{
cin >> a[i];
if (a[i] + a[i - 1] > m)
{
cnt += a[i] + a[i - 1] - m;
a[i] = m - a[i - 1];
}
}
cout << cnt << endl;
return 0;
}
小A的糖果——洛谷3817
最新推荐文章于 2024-10-05 12:07:50 发布