差分矩阵

#include "iostream"
#include "algorithm"
using namespace std;
int main()
{
    int d[110] = {0};
    int n, m;
    cin >> n;
    for(int i = 1; i <= n; i ++)
    {
        int x;
        cin >> x;
        d[i] += x;
        d[i + 1] -= x;
    }
    cin >> m;
    while(m --)
    {
        int l, r, c;
        cin >> l >> r >> c;
        d[l] += c, d[r + 1] -= c;
    }
    for(int i = 1; i <= n; i ++)
    {
        d[i] += d[i - 1];
        cout << d[i] << ' ';
    }
    return 0;
}