_weishiqi66_ @ 2022-12-29 17:26:51
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 6 * int(1e6);
int n, p, ans = 1e9;
int d[N], a[N];
int main() {
cin >> n >> p;
for (int i = 1; i <= n; i++) {
cin >> d[i];
d[i] = d[i] - d[i - 1];
}
for (int i = 1; i <= p; i++) {
int x, y, z;
cin >> x >> y >> z;
d[x] += z;
d[y + 1] -= z;
}
for (int i = 1; i <= n; i++) {
a[i] = d[i] + a[i - 1];
ans = min(ans, a[i]);
}
cout << ans;
return 0;
}
by FQR_ @ 2022-12-29 17:34:21
@weishiqi66 再建一个数组
for (int i = 1; i <= n; i++) {
cin >> b[i];
d[i] = b[i] - b[i - 1];
}
by FQR_ @ 2022-12-29 17:35:59
假设
by _weishiqi66_ @ 2022-12-29 17:36:46
@FQR_ 哦!我居然犯了这么大一个致命错误!谢谢大佬orz