# Submit Info #67767

Problem Lang User Status Time Memory
Static Range Sum cpp RTnF AC 157 ms 15.36 MiB

ケース詳細
Name Status Time Memory
example_00 AC 1 ms 0.45 MiB
max_random_00 AC 157 ms 15.28 MiB
max_random_01 AC 152 ms 15.29 MiB
max_random_02 AC 145 ms 15.36 MiB
max_random_03 AC 144 ms 15.32 MiB
max_random_04 AC 145 ms 15.34 MiB
random_00 AC 117 ms 12.22 MiB
random_01 AC 124 ms 13.50 MiB
random_02 AC 75 ms 6.44 MiB
random_03 AC 43 ms 7.24 MiB
random_04 AC 44 ms 6.04 MiB

#line 1 "Array/StaticRangeSum.test.cpp" #define PROBLEM "https://judge.yosupo.jp/problem/static_range_sum" #line 2 "Template/SmallTemplate.hpp" #include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; constexpr ll MOD = 1e9 + 7; constexpr ll INF = 1e+18; constexpr ld EPS = 1e-12L; constexpr ld PI = 3.14159265358979323846L; #line 2 "Array/CumulativeSum.hpp" template <typename T = ll> class CumulativeSum { vector<T> cs; int n; public: CumulativeSum(const vector<T> &v) : cs(v.size() + 1), n(v.size()) { cs[0] = T(0); for(int i = 1; i <= n; i++) { cs[i] = cs[i - 1] + v[i - 1]; } } // [0, a) 0-n T sum(int a) { assert(0 <= a && a <= n); return cs[a]; } // [a, b) 0-a-b-n T sum(int a, int b) { assert(0 <= a && a <= b && b <= n); return cs[b] - cs[a]; } }; #line 3 "Array/StaticRangeSum.test.cpp" int main() { cin.tie(0); ios::sync_with_stdio(false); int n, q; cin >> n >> q; vector<ll> a(n); for(int i = 0; i < n; i++){ cin >> a[i]; } CumulativeSum cs(a); while(q--){ int l, r; cin >> l >> r; cout << cs.sum(l, r) << '\n'; } }