_djc_ @ 2022-04-15 22:49:55
为什么最后一个点会RE啊?
#include<bits/stdc++.h>
using namespace std;
int minn = 1e9;
int x, y, z;
#define MAXN 100005
int n, p;
int a[MAXN],b[MAXN];
int main() {
cin >> n >> p;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= n; i++) {
b[i] = a[i] - a[i - 1];
}
for (int i = 0; i < p; i++) {
cin >> x >> y >> z;
b[x] += z, b[y + 1] -= z;
}
for (int i = 1; i <= n; i++) {
a[i] = a[i - 1] + b[i];
if(minn > a[i]) minn = a[i];
}
cout << minn;
return 0;
}
by _Remake_ @ 2022-04-15 22:53:20
数组小了 开5e6以上
by zzr1 @ 2022-04-15 22:54:26
@Di_jcheng 往大了开,放心,不会卡内存
by dengchengzhuo @ 2022-04-15 23:19:35
@Di_jcheng 开到5000001就行
by _djc_ @ 2022-04-16 07:54:30
多谢各位