fork download
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4. ll n,q,p,l,r,x,a[1000006],f[1000006];
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  8. freopen("SLR.INP", "r", stdin);
  9. freopen("SLR.OUT", "w", stdout);
  10. cin >> n >> q >> p;
  11. while(q--)
  12. {
  13. cin >> l >> r >> x;
  14. a[r+1] -= x;
  15. a[l] += x;
  16. }
  17. for(int i = 1; i <= n; i++)
  18. {
  19. a[i] += a[i-1];
  20. f[i] += f[i-1] + a[i];
  21. }
  22. while(p--)
  23. {
  24. cin >> l >> r;
  25. cout << f[r] - f[l-1] << '\n';
  26. }
  27. }
  28.  
Success #stdin #stdout 0s 5280KB
stdin
Standard input is empty
stdout
Standard output is empty