#include <bits/stdc++.h>

using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> vi;

const int N=1e5+10;

int n, m, x;
LL b[N];

void work(int l, int r, int c)
{
    b[l]+=c, b[r+1]-=c;
}
int main()
{
    IOS
    cin>>n>>m;
    for(int i=1; i<=n; i++)
    {
        cin>>x;
        work(i, i, x);
    }
    while(m--){
        int l, r;
        cin>>l>>r>>x;
        work(l, r, x);
    }
    for(int i=1; i<=n; i++) b[i]+=b[i-1];
    for(int i=1; i<=n; i++) cout<<b[i]<<" \n"[i==n];
    return 0;
}

差分思想,前缀和的逆运算,差分操作在work函数里,最后当前缀和滚动更新一遍即可

#牛客春招刷题训练营#