就是一个局部的贪心,题目很水,但是我一开始愣是没反应过来
是我太菜 菜是原罪
#include <iostream>
#include <cstdio>
using namespace std;
int n, x, front, now;
long long ans;
int main()
{
scanf("%d%d%d", &n, &x, &front);
for(int i = 2; i <= n; i ++)
{
scanf("%d", &now);
if(now + front > x)
{
ans += now + front - x;
now -= (now + front - x);
}
front = now;
}
printf("%lld\n", ans);
return 0;
}