You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
585 B
29 lines
585 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
const int N = 100010;
|
|
int n, m;
|
|
int a[N], b[N];
|
|
|
|
/**
|
|
* 功能:差分计算
|
|
* @param l 左边界
|
|
* @param r 右边界
|
|
* @param c 值
|
|
*/
|
|
void insert(int l, int r, int c) {
|
|
b[l] += c;
|
|
b[r + 1] -= c;
|
|
}
|
|
int main() {
|
|
cin >> n >> m;
|
|
for (int i = 1; i <= n; i++) cin >> a[i], insert(i, i, a[i]);
|
|
while (m--) {
|
|
int l, r, c;
|
|
cin >> l >> r >> c;
|
|
insert(l, r, c);
|
|
}
|
|
for (int i = 1; i <= n; i++)
|
|
a[i] = a[i - 1] + b[i], printf("%d ", a[i]);
|
|
return 0;
|
|
} |