Advertisement
Rofyda_Elghadban1

Untitled

Jan 10th, 2024
1,212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.08 KB | None | 0 0
  1.  #include <bits/stdc++.h>
  2.  #define ll long long
  3.  #define ull unsigned long long
  4.  #define pi 3.141592654
  5.  #define NUM 1e18
  6.  #define Mod  1'000'000'007
  7.  #define fixed(n) fixed<<setprecision(n)
  8.  #define cin(v) for(auto &i:v) cin >> i ;
  9.  #define cout(v) for(auto &i:v) cout << i  <<" ";
  10.  #define vowel(x) (x=='e'||x=='a'||x=='i'||x=='o'||x=='u')
  11.  #define small(x) (x>=97&&x<=122)
  12.  #define capital(x) (x>=65&&x<=90)
  13.  #define Tolower(s) transform(s.begin(),s.end(),s.begin(),::tolower);
  14.  #define Toupper(s) transform(s.begin(),s.end(),s.begin(),::toupper);
  15.  #define sz(x) (int)(x.size())
  16.  #define all(v) ((v).begin()), ((v).end())
  17.  #define allr(v) ((v).rbegin()), ((v).rend())
  18.  #define updmax(a,b) a=max(a,b)
  19.  #define updmin(a,b) a=min(a,b)
  20.  #define ceil(a,b) ((a/b)+(a%b?1:0))
  21.  /* asc -> 1 2 3 ,des -> 3 2 1 */
  22.  
  23.  /***********************************************************************************/
  24.  using namespace std;
  25.  void Rofyda_Elghadban(){
  26.   #ifndef ONLINE_JUDGE  
  27.     freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  28.    #endif
  29.     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  30.  }
  31.  ll partial[10000001]{},partial2[10000001]{};
  32.  void solve(){
  33.   ll n,m,q,counter=0;
  34.   cin>>n>>m>>q;
  35.   vector<ll>v(n),k,p;
  36.   cin(v);
  37.   while(m--){
  38.     ll l,r,d;
  39.     cin>>l>>r>>d;
  40.     p.push_back(l);
  41.     p.push_back(r);
  42.     p.push_back(d);
  43.   }
  44.   map<ll,ll>mp;
  45.   ll qq=q;
  46.   while(q--){
  47.     ll x,y;
  48.     cin>>x>>y;
  49.     k.push_back(x);
  50.     k.push_back(y);
  51.     partial2[x]+=1;
  52.     partial2[y+1]-=1;
  53.   }
  54.   for(ll i=1;i<=qq;i++){
  55.     partial2[i]+=partial2[i-1];
  56.   }
  57.   for(ll i=0;i<qq;i++){
  58.     mp[i+1]=partial2[i+1];
  59.   }
  60.   for(ll i=0;i<p.size();i+=3){
  61.     counter++;
  62.     partial[p[i]]+=(p[i+2]*mp[counter]);
  63.     partial[p[i+1]+1]-=(p[i+2]*mp[counter]);
  64.   }
  65.   for(ll i=1;i<=n;i++){
  66.     partial[i]+=partial[i-1];
  67.   }
  68.   for(ll i=0;i<n;i++){
  69.     v[i]+=partial[i+1];
  70.   }
  71.   cout(v);
  72.   cout<<"\n";
  73.  }
  74.  
  75.  int main(){
  76.   Rofyda_Elghadban();
  77.   // int t;
  78.   // cin>>t;
  79.   // while(t--){
  80.   //   solve();
  81.   // }
  82.   solve();
  83.   return 0;
  84.  }
  85.  
  86.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement