Advertisement
Rofyda_Elghadban1

Untitled

Sep 1st, 2023
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.16 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+1);
  70. v[0]=0;
  71. for(int i=1;i<n+1;i++){
  72. cin>>v[i];
  73. }
  74. ll prefix[n+2]{};
  75. int q;
  76. cin>>q;
  77. while(q--){
  78. int t,l,r,sum=0;
  79. cin>>t>>l>>r;
  80. if(t==1){
  81. for(int i=1;i<=v.size();i++){
  82. prefix[i]=v[i]+prefix[i-1];
  83. }
  84. }else if(t==2){
  85. sort(all(v));
  86. for(int i=1;i<=v.size();i++){
  87. prefix[i]=v[i]+prefix[i-1];
  88. }
  89. }
  90. cout<<prefix[r]-prefix[l-1]<<" ";
  91. cout<<"\n";
  92. }
  93.  
  94.  
  95.  
  96.  
  97. return 0;
  98. }
  99.  
  100.  
  101. /*
  102.  
  103. * * * * * * * * * * * * * * * * * * * * * * * * * *
  104. * * * * * * *
  105. * * * * * * *
  106. * * * * * * *
  107. * * * * * * * * * * * * * * * * * * * * * * * * * *
  108. * * * * * *
  109. * * * * * *
  110. * * * * * *
  111. * * * * * *
  112. * * * * * *
  113. * * * * * *
  114. * * * * * * * * * * * * * * * * * * *
  115.  
  116. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement