Submit Info #68547

Problem Lang User Status Time Memory
Static Range Sum cpp14 SamGeisler AC 620 ms 15.34 MiB

ケース詳細
Name Status Time Memory
example_00 AC 1 ms 0.41 MiB
max_random_00 AC 619 ms 15.27 MiB
max_random_01 AC 619 ms 15.27 MiB
max_random_02 AC 619 ms 15.27 MiB
max_random_03 AC 618 ms 15.34 MiB
max_random_04 AC 620 ms 15.26 MiB
random_00 AC 498 ms 12.19 MiB
random_01 AC 533 ms 13.48 MiB
random_02 AC 369 ms 6.41 MiB
random_03 AC 138 ms 7.23 MiB
random_04 AC 169 ms 5.93 MiB

#include <iostream> #include <vector> using namespace std; int main(){ int n,q; cin >> n >> q; vector<long long> a(n); for(int i = 0; i<n; i++){ cin >> a[i]; } vector<long long> prefix_sums(n+1); prefix_sums[0] = 0; for(int i = 1; i<n+1; i++){ prefix_sums[i] = prefix_sums[i-1]+a[i-1]; } int l,r; for(int i = 0; i<q; i++){ cin >> l >> r; cout << prefix_sums[r] - prefix_sums[l] << endl; } return 0; }