Advertisement
Josif_tepe

Untitled

Feb 18th, 2022
713
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <vector>
  4. #include <cstring>
  5. using namespace std;
  6.  
  7. int main() {
  8.     int n;
  9.     cin >> n;
  10.     int k;
  11.     cin >> k;
  12.     vector<int> pref_sum(n + 1, 0);
  13.     for(int i = 0; i < k; i++) {
  14.         int x, y, z;
  15.         cin >> x >> y >> z;
  16.         pref_sum[x] += z;
  17.         pref_sum[y + 1] -= z;
  18.     }
  19.     int sum = 0;
  20.     for(int i = 0; i < n; i++) {
  21.         sum += pref_sum[i];
  22.         cout << sum << " ";
  23.     }
  24.     return 0;
  25. }
  26. // min(1, )
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement