Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <cstring>
- using namespace std;
- typedef long long ll;
- const int maxn = 1e5 + 100;
- int pref_sum[maxn];
- int query(int i, int j) {
- if(i == 0) {
- return pref_sum[j];
- }
- return pref_sum[j] - pref_sum[i - 1];
- }
- int main() {
- int n;
- cin >> n;
- vector<int> v(n);
- int sum = 0;
- for(int i = 0; i < n; i++) {
- cin >> v[i];
- sum += v[i];
- pref_sum[i] = sum;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement