fork download
  1. #include<bits/stdc++.h>
  2. #define ull unsigned long long
  3. #define ll long long
  4. #define all(x) x.begin(), x.end()
  5. using namespace std;
  6. const int maxn = 2e5 + 1;
  7. ll A[maxn], D[maxn];
  8. int main() {
  9. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  10. // freopen("file.inp","r",stdin);
  11. // freopen("file.out","w",stdout);
  12. int n, q;
  13. cin >> n >> q;
  14. int l, r, x, num;
  15. for (int i = 1; i <= q; ++i) {
  16. cin >> num >> l >> r >> x;
  17. if (num == 1) {
  18. D[l - 1] += x;
  19. D[r] -= x;
  20. }
  21. else {
  22. D[l - 1] -= x;
  23. D[r] += x;
  24. }
  25. }
  26. for (int i = 1; i <= n; ++i) {
  27. A[i] = A[i-1] + D[i-1];
  28. }
  29. for (int i = 1; i <= n; ++i) {
  30. cout << A[i] << " ";
  31. }
  32. }
Success #stdin #stdout 0.01s 5212KB
stdin
Standard input is empty
stdout
0