Submit Info #68037

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

ケース詳細
Name Status Time Memory
example_00 AC 1 ms 0.45 MiB
max_random_00 AC 630 ms 15.29 MiB
max_random_01 AC 627 ms 15.27 MiB
max_random_02 AC 669 ms 15.32 MiB
max_random_03 AC 621 ms 15.32 MiB
max_random_04 AC 623 ms 15.27 MiB
random_00 AC 503 ms 12.23 MiB
random_01 AC 537 ms 13.45 MiB
random_02 AC 369 ms 6.42 MiB
random_03 AC 140 ms 7.32 MiB
random_04 AC 169 ms 5.98 MiB

#include <iostream> using namespace std; typedef long long int ll; int n, q; ll arr[500000]; ll ps[500001]; int main() { cin >> n >> q; for (int i = 0; i < n; i++) { cin >> arr[i]; } ll t = 0; for (int i = 0; i < n; i++) { ps[i] = t; t += arr[i]; } ps[n] = t; int a, b; for (int i = 0; i < q; i++) { cin >> a >> b; cout << ps[b] - ps[a] << endl; } }