SHARE
TWEET

Untitled

a guest Nov 9th, 2019 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const int N=1e6+1;
  4. long long a[N],qs[N];
  5. int main()
  6. {
  7.     int n,t;
  8.     scanf("%d%d",&n,&t);
  9.     for(int i=1;i<=n;++i)
  10.         scanf("%lld",&a[i]);
  11.     for(int i=0;i<t;++i){
  12.         int l,r,v;
  13.         scanf("%d%d%d",&l,&r,&v);
  14.         qs[l]+=v;
  15.         qs[r+1]-=v;
  16.     }
  17.     for(int i=1;i<=n;++i){
  18.         qs[i]=qs[i-1]+qs[i];
  19.         a[i]+=qs[i];
  20.         printf("%lld ",a[i]);
  21.     }
  22.     return 0;
  23. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top