Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #pragma GCC optimize("unroll-loops")
- #pragma GCC optimize("Ofast")
- #pragma GCC optimize("-O3")
- #define isz(x) int(x.size())
- #define all(x) x.begin(),x.end()
- #define rall(x) x.rbegin(),x.rend()
- #define ll long long
- #define pii pair<int,int>
- #define fi first
- #define se second
- #define isz(x) int(x.size())
- #define ull unsigned long long
- #define vull vector<ull>
- #define vvull vector<vull>
- #define vb vector<bool>
- #define vvb vector<vb>
- #define vvvb vector<vvb>
- #define vvvvb vector<vvvb>
- #define vi vector<int>
- #define vll vector<ll>
- #define vch vector<char>
- #define vvch vector<vch>
- #define vvvch vector<vvch>
- #define vvi vector<vector<int>>
- #define vvvi vector<vvi>
- #define vvvvi vector<vvvi>
- #define vvvvvi vector<vvvvi>
- #define vvll vector<vector<ll>>
- #define vvvll vector<vvll>
- #define vvvvll vector<vvvll>
- #define vvvvvll vector<vvvvll>
- #define vpii vector<pair<int,int>>
- #define vvpii vector<vpii>
- #define forn(i,n) for(int i=0;i<(int)n;++i)
- #define pb push_back
- using namespace std;
- const double EPS=1e-9;
- const int UNDEF = -1;
- const int MOD = 1e9+7;
- const int INF = 1e9;
- int main() {
- //freopen("input.txt","r",stdin);
- //freopen("output.txt","w",stdout);
- int n;
- cin>>n;
- vi a(1+n,0);
- for(int i=1;i<=n;++i) cin>>a[i];
- int q;
- cin>>q;
- vll diff(n);
- forn(i,n) diff[i]=a[i+1]-a[i];
- while(q-->0){
- int l,r,d;
- cin>>l>>r>>d;
- diff[l-1]+=d;
- if(r<n) diff[r]-=d;
- }
- vll preff(1+n,0);
- for(int i=1;i<=n;++i) preff[i]=preff[i-1]+diff[i-1];
- for(int i=1;i<=n;++i) cout<<preff[i]<<' ';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement