进行区间更新之后 必须要用前缀和还原才能得到原数组
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 3;
int a[N],diff[N];
void solve(int n, int m)
{
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i <= n; i++) diff[i] = a[i] - a[i-1];
int x, y, z;
while(m--)
{
cin >> x >> y >> z;
diff[x] += z;
diff[y+1] -= z;
}
//前缀和恢复
for (int i = 1; i <= n; i++) a[i] = diff[i] + a[i-1];
for (int i = 1; i <= n; i++) cout << a[i] << " \n"[i == n];
}
int main()
{
int n, m;
while(cin >> n >> m) solve(n,m);
return 0;
}