fork download
  1. #include <bits/stdc++.h>
  2. #define int long long
  3. #define el '\n'
  4. #define oo LLONG_MAX >> 2
  5. #define all(x) x.begin(), x.end()
  6. #define allr(x) x.rbegin(), x.rend()
  7. #define pb push_back
  8. #define pep_Guardiola \
  9.   ios::sync_with_stdio(0); \
  10.   cin.tie(0); \
  11.   cout.tie(0);
  12. using namespace std;
  13.  
  14. signed main() {
  15. pep_Guardiola int n, q;
  16. cin >> n >> q;
  17. vector<int> a(n + 2), b(n + 2);
  18. while (q--) {
  19. int l, r;
  20. cin >> l >> r;
  21. a[l]++;
  22. a[r + 1]--;
  23. b[l] -= l;
  24. b[r + 1] += l;
  25. }
  26. for (int i = 1; i <= n; i++)
  27. a[i] += a[i - 1], b[i] += b[i - 1], cout << a[i] + a[i] * i + b[i] << ' ';
  28. }
Success #stdin #stdout 0s 5316KB
stdin
5 3
2 3
2 2
2 2
stdout
0 3 2 0 0