Advertisement
Josif_tepe

Untitled

Mar 21st, 2025
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <cstring>
  5. using namespace std;
  6. typedef long long ll;
  7. const int maxn = 1e5 + 100;
  8. int pref_sum[maxn];
  9.  
  10. int query(int i, int j) {
  11.     if(i == 0) {
  12.         return pref_sum[j];
  13.     }
  14.     return pref_sum[j] - pref_sum[i - 1];
  15. }
  16.  
  17.  
  18. int main() {
  19.    
  20.     int n;
  21.     cin >> n;
  22.     vector<int> v(n);
  23.    
  24.     int sum = 0;
  25.     for(int i = 0; i < n; i++) {
  26.         cin >> v[i];
  27.         sum += v[i];
  28.        
  29.         pref_sum[i] = sum;
  30.     }
  31.     return 0;
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement