Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <vector>
- #include <cstring>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- int k;
- cin >> k;
- vector<int> pref_sum(n + 1, 0);
- for(int i = 0; i < k; i++) {
- int x, y, z;
- cin >> x >> y >> z;
- pref_sum[x] += z;
- pref_sum[y + 1] -= z;
- }
- int sum = 0;
- for(int i = 0; i < n; i++) {
- sum += pref_sum[i];
- cout << sum << " ";
- }
- return 0;
- }
- // min(1, )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement