Submit Info #68425

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

ケース詳細
Name Status Time Memory
example_00 AC 1 ms 0.45 MiB
max_random_00 AC 446 ms 15.27 MiB
max_random_01 AC 434 ms 15.29 MiB
max_random_02 AC 431 ms 15.29 MiB
max_random_03 AC 430 ms 15.32 MiB
max_random_04 AC 443 ms 15.32 MiB
random_00 AC 354 ms 12.21 MiB
random_01 AC 366 ms 13.45 MiB
random_02 AC 293 ms 6.35 MiB
random_03 AC 60 ms 7.25 MiB
random_04 AC 110 ms 6.05 MiB

#include <iostream> #include <vector> using namespace std; using vi = vector<int>; using vll = vector<long long>; int main() { ios_base::sync_with_stdio(0); int N, Q; cin >> N >> Q; vll vals (N); for (int i {0}; i < N; i++) cin >> vals[i]; vll psum (N + 1); for (int i {0}; i < N; i++) psum[i+1] = psum[i] + vals[i]; for (int i {0}; i < Q; i++) { int a, b; cin >> a >> b; cout << psum[b] - psum[a] << '\n'; } return 0; }