Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "bits/stdc++.h"
- using namespace std;
- int main () {
- int n, q;
- cin >> n >> q;
- int a[n + 1];
- for (int i = 0; i <= n; ++i) a[i] = 0;
- for (int i = 1; i <= q; ++i) {
- int l, r, x;
- cin >> l >> r >> x;
- a[l] += x;
- if (r + 1 <= n) {
- a[r + 1] -= x;
- }
- }
- int sum = 0;
- int pref[n + 1];
- for (int i = 1; i <= n; ++i) {
- sum += a[i];
- pref[i] = sum;
- }
- for (int i = 1; i <= n; ++i) cout << pref[i] << ' ';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement