Submit Info #68281

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

ケース詳細
Name Status Time Memory
example_00 AC 1 ms 0.42 MiB
max_random_00 AC 619 ms 13.34 MiB
max_random_01 AC 641 ms 13.35 MiB
max_random_02 AC 621 ms 13.32 MiB
max_random_03 AC 626 ms 13.32 MiB
max_random_04 AC 627 ms 13.34 MiB
random_00 AC 493 ms 10.80 MiB
random_01 AC 516 ms 11.70 MiB
random_02 AC 369 ms 6.13 MiB
random_03 AC 132 ms 5.57 MiB
random_04 AC 164 ms 4.95 MiB

#include <iostream> #include <bits/stdc++.h> using namespace std; #define ll long long int main() { int n, q; cin >> n >> q; int nums[n + 1]; nums[0] = 0; for (int i = 1; i <= n; i++) { cin >> nums[i]; } ll prefix[n+1]; ll sum = 0; prefix[0] = 0; for (int i = 1; i <= n; i++) { sum += nums[i]; prefix[i] = sum; } for (int i = 0; i < q; i++) { int l, r; cin >> l >> r; l++; cout << prefix[r] - prefix[l - 1] << endl; } }