Advertisement
Rofyda_Elghadban1

Untitled

Sep 1st, 2023
659
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.67 KB | None | 0 0
  1.  /*Rofyda Mohamed Hamed Hamed Elghadban*/
  2.  //#include <bits/stdc++.h>
  3.  #include <iostream>
  4.  #include <iomanip>
  5.  #include <cmath>
  6.  #include <algorithm>
  7.  #include <cstdlib>
  8.  #include <limits.h>
  9.  #include <string>
  10.  #include <vector>
  11.  #include <map>
  12.  #include <stack>
  13.  #include <set>
  14.  #include <deque>
  15.  #include <fstream>
  16.  #include <bitset>
  17.  #include <cmath>
  18.  #include <numeric>
  19.  #include <cstring>
  20.  #include <utility>
  21.  #include <queue>
  22.  
  23.  /***********************************************************************************/
  24.  
  25.  #define ll long long
  26.  #define ull unsigned long long
  27.  #define pi 3.141592654
  28.  #define NUM 1e18
  29.  #define Mod  1'000'000'007
  30.  #define fixed(n) fixed<<setprecision(n)
  31.  #define cin(v) for(auto &i:v) cin >> i ;
  32.  #define cout(v) for(auto &i:v) cout << i  <<" ";
  33.  #define Ceil(a,b) ((a/b)+(a%b ? 1 : 0))
  34.  #define vowel(x) (x=='e'||x=='a'||x=='i'||x=='o'||x=='u')
  35.  #define small(x) (x>=97&&x<=122)
  36.  #define capital(x) (x>=65&&x<=90)
  37.  #define Tolower(s) transform(s.begin(),s.end(),s.begin(),::tolower);
  38.  #define Toupper(s) transform(s.begin(),s.end(),s.begin(),::toupper);
  39.  #define all(v) ((v).begin()), ((v).end())
  40.  #define allr(v) ((v).rbegin()), ((v).rend())
  41.  #define updmax(a,b) a=max(a,b)
  42.  #define updmin(a,b) a=min(a,b)
  43.  #define ceil(a,b) ((a/b)+(a%b?1:0))
  44.  /* asc -> 1 2 3 ,des -> 3 2 1 */
  45.  
  46.  /***********************************************************************************/
  47.  
  48.  using namespace std;
  49.  
  50.  void Rofyda_Elghadban(){
  51.   #ifndef ONLINE_JUDGE  
  52.     freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  53.    #endif
  54.     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  55.  }
  56.  
  57.  void solve(){
  58.  }
  59.  
  60.  int main(){
  61.   Rofyda_Elghadban();
  62.  //freopen("input.txt","r",stdin);
  63.  //freopen("output.txt","r",stdout);
  64.  
  65.  //solve();
  66.  
  67. //  int n;
  68. //  cin>>n;
  69. //  vector<int>v(n);
  70. //  cin(v);
  71. //  int t;
  72. //  cin>>t;
  73. //  while(t--){
  74. //   int t,l,r,sum=0;
  75. //   cin>>t>>l>>r;
  76. //   ll prefix[n+1]{};
  77. //   if(t==1){
  78. //     for(int i=l;i<=r;i++){
  79. //       prefix[i]=prefix[i-1]+v[i-1];
  80. //     }
  81. //   }else if(t==2){
  82. //     sort(all(v));
  83. //     for(int i=l;i<=r;i++){
  84. //       prefix[i]=prefix[i-1]+v[i-1];
  85. //     }
  86. //   }
  87. //   for(ll i=l;i<=r;i++){
  88. //     cout<<prefix[i]-<<" ";
  89. //   }cout<<"\n";
  90. //  }
  91.  
  92.  
  93.  int n;
  94.  cin>>n;
  95.  vector<int>v(n);
  96.  cin(v);
  97.  int t;
  98.  cin>>t;
  99.  while(t--){
  100.   int t,l,r,sum=0;
  101.   cin>>t>>l>>r;
  102.   ll partial[n+1]{};
  103.   if(t==1){
  104.     for(int i=l;i<r;i++){
  105.       //sum+=v[i];
  106.       partial[i]+=partial[i-1];
  107.     }
  108.   }else if(t==2){
  109.     sort(all(v));
  110.     for(int i=l;i<r;i++){
  111.       //sum+=v[i];
  112.       partial[i]+=partial[i-1];
  113.     }
  114.   }
  115.   for(ll i=l;i<r;i++){
  116.     v[i]+=partial[i+1];
  117.     cout<<partial[i]<<" ";
  118.   }
  119.   //cout<<sum;
  120.   cout<<"\n";
  121.  }
  122.  
  123.  
  124.  return 0;
  125. }
  126.  
  127.  
  128. /*
  129.  
  130. * * * * * * * *    * * * * * * * *    * * * * * * * *    *             *
  131. *             *    *             *    *                  *             *
  132. *             *    *             *    *                  *             *
  133. *             *    *             *    *                  *             *
  134. * * * * * * * *    *             *    * * * * * * * *    * * * * * * * *
  135. * *                *             *    *                                *
  136. *   *              *             *    *                                *
  137. *     *            *             *    *                                *
  138. *       *          *             *    *                                *
  139. *         *        *             *    *                                *
  140. *           *      *             *    *                                *    
  141. *             *    * * * * * * * *    *                  * * * * * * * *
  142.  
  143. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement