Submit Info #65812

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

ケース詳細
Name Status Time Memory
example_00 AC 1 ms 0.41 MiB
max_random_00 AC 633 ms 15.26 MiB
max_random_01 AC 626 ms 15.26 MiB
max_random_02 AC 630 ms 15.34 MiB
max_random_03 AC 633 ms 15.26 MiB
max_random_04 AC 638 ms 15.26 MiB
random_00 AC 517 ms 12.30 MiB
random_01 AC 543 ms 13.44 MiB
random_02 AC 382 ms 6.35 MiB
random_03 AC 140 ms 7.22 MiB
random_04 AC 170 ms 5.93 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"; } }