test/yosupo/data_structure/static_range_sum.test.cpp
✅
AC
· 最終更新 2026-09-07
· GitHub
問題: https://judge.yosupo.jp/problem/static_range_sum
依存するヘッダ(1)
-
✅
累積和
lib/algorithm/prefix_sum.hpp
実装
// competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/static_range_sum
#include <cstdint>
#include <iostream>
#include <vector>
#include "algorithm/prefix_sum.hpp"
int main(void) {
int n, q;
std::cin >> n >> q;
std::vector<std::int64_t> a(n);
for (auto &e : a) std::cin >> e;
PrefixSum<std::int64_t> ps(a);
while (q--) {
int l, r;
std::cin >> l >> r;
std::cout << ps.sum(l, r) << '\n';
}
return 0;
}