Submit Info #68619

Problem Lang User Status Time Memory
Static Range Sum cpp (anonymous) AC 659 ms 15.32 MiB

ケース詳細
Name Status Time Memory
example_00 AC 1 ms 0.42 MiB
max_random_00 AC 633 ms 15.26 MiB
max_random_01 AC 659 ms 15.32 MiB
max_random_02 AC 637 ms 15.26 MiB
max_random_03 AC 640 ms 15.22 MiB
max_random_04 AC 638 ms 15.32 MiB
random_00 AC 515 ms 12.28 MiB
random_01 AC 533 ms 13.48 MiB
random_02 AC 379 ms 6.44 MiB
random_03 AC 138 ms 7.22 MiB
random_04 AC 170 ms 6.02 MiB

#include <bits/stdc++.h> using namespace std; #define sz(x) (int)size(x) using ll = long long; using vl = vector<ll>; vl psum(const vl& a) { vl psum(sz(a)+1); for (int i = 0; i < sz(a); ++i) psum[i+1] = psum[i]+a[i]; // or partial_sum(begin(a),end(a),begin(psum)+1); return psum; } int main() { int N, Q; cin >> N >> Q; vl a(N); for (ll& x: a) cin >> x; vl p = psum(a); for (int i = 0; i < Q; ++i) { int l, r; cin >> l >> r; cout << p[r] - p[l] << "\n"; } }