答案

小唐唐  •  18小时前


include

using namespace std; const int MAXN = 1000005; long long shuzu[MAXN];
long long nn[MAXN];
int main() {

ios::sync_with_stdio(false);
cin.tie(nullptr);
int a, b;  
cin >> a >> b;
for (int i = 1; i <= a; ++i) {
    cin >> shuzu[i];
}
nn[1] = shuzu[1];  
for (int i = 2; i <= a; ++i) {
    nn[i] = shuzu[i] - shuzu[i - 1]; 
}
for (int i = 0; i < b; ++i) {  
    int l, r, c;
    cin >> l >> r >> c;
    nn[l] += c;                
    if (r + 1 <= a) {         
        nn[r + 1] -= c;       
    }
}

shuzu[1] = nn[1];
cout << shuzu[1] << " ";
for (int i = 2; i <= a; ++i) {
    shuzu[i] = shuzu[i - 1] + nn[i];  
    cout << shuzu[i] << " ";          
}
return 0;

}


评论:

请先登录,才能进行评论