fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. const long long MaxN=1e3;
  4. long long m,n,p,l,r,x;
  5. pair<long long,long long>a[MaxN+5];
  6. int main()
  7. {
  8. ios_base::sync_with_stdio(0);
  9. cin.tie(0);
  10. if (fopen("weath.inp", "r"))
  11. {
  12. freopen("weath.inp", "r", stdin);
  13. freopen("weath.out", "w", stdout);
  14. }
  15. cin >> m >> n;
  16. for (long long i=1; i<=m; i++)
  17. {
  18. cin >> a[i].first;
  19. a[i].second=0;
  20. }
  21. while (n--)
  22. {
  23. cin >> l >> r >> x;
  24. for (long long i=1; i<=m; i++)
  25. {
  26. if(a[i].first>=l&&a[i].first<=r)
  27. {
  28. if(a[i].first%2==l%2)
  29. {
  30. a[i].second+=x;
  31. }
  32. else
  33. {
  34. a[i].second-=x;
  35. }
  36. }
  37. }
  38. }
  39. for (long long i=1; i<=m; i++)
  40. {
  41. cout << a[i].second << "\n" ;
  42. }
  43. }
  44.  
Success #stdin #stdout 0.01s 5316KB
stdin
Standard input is empty
stdout
Standard output is empty