Submit Info #67564

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

ケース詳細
Name Status Time Memory
example_00 AC 1 ms 0.43 MiB
max_random_00 AC 623 ms 11.50 MiB
max_random_01 AC 621 ms 11.45 MiB
max_random_02 AC 626 ms 11.45 MiB
max_random_03 AC 625 ms 11.52 MiB
max_random_04 AC 626 ms 11.45 MiB
random_00 AC 500 ms 9.30 MiB
random_01 AC 534 ms 9.85 MiB
random_02 AC 368 ms 5.92 MiB
random_03 AC 138 ms 3.97 MiB
random_04 AC 173 ms 3.89 MiB

#include <iostream> #include <vector> using namespace std; using ll = long long; int main() { int N, Q; cin >> N >> Q; vector<ll> sums(N); cin >> sums[0]; for(int i = 1; i < N; i++) { cin >> sums[i]; sums[i] += sums[i-1]; } for(int i = 0; i < Q; i++) { int lower; cin >> lower; int higher; cin >> higher; ll ans = sums[higher-1]; if(lower > 0) { ans -= sums[lower-1]; } cout << ans << endl; } }