SHARE
TWEET

Untitled

a guest Nov 15th, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. #include<vector>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. int main(){
  8.  
  9. int n;
  10. cin >> n;
  11.  
  12. vector<int> d(n, 0);
  13. int m; cin >> m;
  14.  
  15. for (int i = 0; i < m; i++) {
  16.     int a, b, k;
  17.     cin >> a >> b >> k;
  18.     d[a] += k;
  19.  
  20.     if (b < n-1)
  21.         d[b] -= k;
  22. }
  23. int zbir = 0;
  24.  
  25. for (int i = 0; i < n; i++) {
  26.     zbir += d[i];
  27.     cout << zbir << endl;
  28. }
  29.  
  30.     return 0;
  31. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top