Submit Info #67066

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

ケース詳細
Name Status Time Memory
example_00 AC 1 ms 0.42 MiB
max_random_00 AC 658 ms 15.37 MiB
max_random_01 AC 656 ms 15.36 MiB
max_random_02 AC 659 ms 15.36 MiB
max_random_03 AC 660 ms 15.36 MiB
max_random_04 AC 668 ms 15.42 MiB
random_00 AC 516 ms 12.52 MiB
random_01 AC 540 ms 13.20 MiB
random_02 AC 376 ms 9.05 MiB
random_03 AC 140 ms 4.31 MiB
random_04 AC 176 ms 4.79 MiB

#include <iostream> #include <vector> using namespace std; using ll = long long; int main() { int n, q; cin >> n >> q; ll psum[n+1] = {0}; ll temp; for (int i=1; i<=n; i++) { cin >> temp; psum[i] = psum[i-1] + temp; } ll l,r; vector<ll> answers; for (int i=0; i<q; i++) { cin >> l >> r; answers.push_back(psum[r]-psum[l]); } for (ll x : answers) { cout << x << endl; } }