Submit Info #67266

Problem Lang User Status Time Memory
Static Range Sum cpp piddy AC 78 ms 13.45 MiB

ケース詳細
Name Status Time Memory
example_00 AC 1 ms 0.45 MiB
max_random_00 AC 74 ms 13.44 MiB
max_random_01 AC 78 ms 13.45 MiB
max_random_02 AC 75 ms 13.45 MiB
max_random_03 AC 75 ms 13.45 MiB
max_random_04 AC 75 ms 13.45 MiB
random_00 AC 62 ms 10.76 MiB
random_01 AC 65 ms 11.64 MiB
random_02 AC 40 ms 6.15 MiB
random_03 AC 19 ms 5.72 MiB
random_04 AC 21 ms 4.98 MiB

#include <iostream> struct fast_I { private : char c = ' '; bool neg; template<typename T> T& read(T& n) { n = 0; neg = false; while (c == ' ' || c == '\n') c = getchar(); if (c == '-') { neg = true; c = getchar(); } while ('0' <= c && c <= '9') { (n *= 10) += c - '0'; c = getchar(); } return n *= (neg ? -1 : 1); } public : void setup() const { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } template<typename T> T& operator()(T& t) { return read(t); } template<typename Top, typename... Rest> void operator()(Top&& top, Rest&&... rest) { read(top); operator()(std::forward<Rest>(rest)...); } }; template<> std::string& fast_I::read(std::string& s) { s.clear(); while (c == ' ' || c == '\n') c = getchar(); while (c != ' ' && c != '\n') { s.push_back(c); c = getchar(); } return s; } fast_I in; int main() { in.setup(); int N, Q; in(N, Q); int A[N]; for (int i = 0; i < N; i++) in(A[i]); long long sum[N + 1] = {}; for (int i = 0; i < N; i++) sum[i + 1] = sum[i] + A[i]; while (Q--) { int l, r; in(l, r); std::cout << sum[r] - sum[l] << '\n'; } }