Advertisement
KinDeR___

Untitled

Nov 23rd, 2023
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. #pragma GCC optimize("unroll-loops")
  4. #pragma GCC optimize("Ofast")
  5. #pragma GCC optimize("-O3")
  6.  
  7. #define isz(x) int(x.size())
  8. #define all(x) x.begin(),x.end()
  9. #define rall(x) x.rbegin(),x.rend()
  10. #define ll long long
  11. #define pii pair<int,int>
  12. #define fi first
  13. #define se second
  14. #define isz(x) int(x.size())
  15. #define ull unsigned long long
  16. #define vull vector<ull>
  17. #define vvull vector<vull>
  18. #define vb vector<bool>
  19. #define vvb vector<vb>
  20. #define vvvb vector<vvb>
  21. #define vvvvb vector<vvvb>
  22. #define vi vector<int>
  23. #define vll vector<ll>
  24. #define vch vector<char>
  25. #define vvch vector<vch>
  26. #define vvvch vector<vvch>
  27. #define vvi vector<vector<int>>
  28. #define vvvi vector<vvi>
  29. #define vvvvi vector<vvvi>
  30. #define vvvvvi vector<vvvvi>
  31. #define vvll vector<vector<ll>>
  32. #define vvvll vector<vvll>
  33. #define vvvvll vector<vvvll>
  34. #define vvvvvll vector<vvvvll>
  35. #define vpii vector<pair<int,int>>
  36. #define vvpii vector<vpii>
  37. #define forn(i,n) for(int i=0;i<(int)n;++i)
  38. #define pb push_back
  39.  
  40. using namespace std;
  41.  
  42. const double EPS=1e-9;
  43. const int UNDEF = -1;
  44. const int MOD = 1e9+7;
  45. const int INF = 1e9;
  46.  
  47. int main() {
  48.  
  49. //freopen("input.txt","r",stdin);
  50. //freopen("output.txt","w",stdout);
  51.  
  52. int n;
  53. cin>>n;
  54.  
  55. vi a(1+n,0);
  56.  
  57. for(int i=1;i<=n;++i) cin>>a[i];
  58.  
  59. int q;
  60. cin>>q;
  61.  
  62. vll diff(n);
  63. forn(i,n) diff[i]=a[i+1]-a[i];
  64.  
  65. while(q-->0){
  66. int l,r,d;
  67. cin>>l>>r>>d;
  68. diff[l-1]+=d;
  69. if(r<n) diff[r]-=d;
  70. }
  71.  
  72. vll preff(1+n,0);
  73. for(int i=1;i<=n;++i) preff[i]=preff[i-1]+diff[i-1];
  74.  
  75. for(int i=1;i<=n;++i) cout<<preff[i]<<' ';
  76.  
  77. return 0;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement