Mahmoud_Hawara

Untitled

Jul 5th, 2022
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.34 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #pragma GCC optimize("-Ofast")
  4. #pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
  5. #pragma GCC optimize("-ffast-math")
  6. #pragma GCC optimize("-funroll-loops")
  7. #pragma GCC optimize("-funroll-all-loops,-fpeel-loops,-funswitch-loops")
  8. #define IO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  9. const long long MOD = 1e9 + 7, OO = 1e18;
  10. const double PI = acos(-1);
  11. const int N = 1e6 + 5;
  12. const int dx[4] = {0, 0, 1, -1};
  13. const int dy[4] = {1, -1, 0, 0};
  14.  
  15. long long n, m, k, l[N], r[N], d[N], x, y, occurance[N], a[N], pref[N];
  16.  
  17. int main()
  18. {
  19.     IO
  20.     cin >> n >> m >> k;
  21.     for (int i = 1; i <= n; i++)
  22.     {
  23.         cin >> a[i];
  24.     }  
  25.     for (int i = 1; i <= m; i++)
  26.     {
  27.         cin >> l[i] >> r[i] >> d[i];
  28.     }
  29.     for (int i = 1; i <= k; i++)
  30.     {
  31.         cin >> x >> y;
  32.         occurance[x]++;
  33.         occurance[y + 1]--;
  34.     }
  35.     for (int i = 1; i <= m; i++)
  36.     {
  37.         occurance[i] += occurance[i - 1];
  38.         d[i] *= occurance[i];
  39.     }
  40.     for (int i = 1; i <= m; i++)
  41.     {
  42.         pref[l[i]] += d[i];
  43.         pref[r[i] + 1] -= d[i];
  44.     }
  45.     for (int i = 1; i <= n; i++)
  46.     {
  47.         pref[i] += pref[i - 1];
  48.     }
  49.     for (int i = 1; i <= n; i++)
  50.     {
  51.         cout << a[i] + pref[i] << ' ';
  52.     }
  53.     return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment