数组下标不同
by luoguandy @ 2024-01-23 21:02:44
https://www.luogu.com.cn/record/144034810
第16行加个等于号
by luoguandy @ 2024-01-23 21:04:49
ACcode:
```cpp
//some define
#define MAXS 0x3f3f3f
#define MINS -0x3f3f3f
#define mm(a, b) memset(a, b, sizeof(a))
#define ll long long
#define MAX(x,y) ((x)>(y)?(x):(y))
#define MIN(x,y) ((x)<(y)?(x):(y))
#include <bits/stdc++.h> //Niubility Head File
using namespace std;
//variables and structions
ll n, x, a[100050], ans = 0;
//functions
//main function
signed main() {
scanf("%ld %ld", &n, &x);
for (int i = 1; i <= n; i++)
{
scanf("%ld", &a[i]);
}
for (int i = 1; i <=n; i++)
{
if (a[i] + a[i + 1] > x)
{
ans += (a[i + 1] - x + a[i]);
a[i + 1] = x - a[i];
}
}
printf("%ld", ans);
return 0;
}
``` @[JMCJimmyMaker](/user/775490)
by luoguandy @ 2024-01-23 21:06:26
@[JMCJimmyMaker](/user/775490)
by luoguandy @ 2024-01-23 21:06:51
求关
by luoguandy @ 2024-01-23 21:07:34
@[luoguandy](/user/1011214) 还是错两组awa
by JMCJimmyMaker @ 2024-01-23 21:11:05
@[luoguandy](/user/1011214) 关注哩
by JMCJimmyMaker @ 2024-01-23 21:12:25
@[JMCJimmyMaker](/user/775490) 谢谢
[https://www.luogu.com.cn/record/144037033](https://www.luogu.com.cn/record/144037033)
by luoguandy @ 2024-01-23 21:15:14
用scanf读入的时候%ld表示的是long int,上限和int一样,改用%lld就行了
https://www.luogu.com.cn/record/146500187
by LH4432 @ 2024-02-07 22:13:58