样例
耐心在纸上试一试!加油
C++ 代码
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n,m;
int s[N];
void chafen(int x, int y, int z){
s[x]+=z;
s[y+1]-=z;
}
int main(){
cin>>n>>m;
for(int i =1;i<=n;i++) cin>>s[i];//0调到1
for (int i = n; i; i -- ) s[i] -= s[i - 1];
while(m--){
int l=0,r=0,c=0;
cin>>l>>r>>c;
chafen(l,r,c);
//s[l] += c, s[r + 1] -= c;
}
for (int i = 1; i <= n; i ++ ) s[i] += s[i - 1];
for(int i =1;i<=n;i++) cout<<s[i]<<' ';//0调到1到n
cout<<endl;
return 0;
}