algo — C++23 日本語リファレンス GitHub

test/yosupo/data_structure/point_add_range_sum.test.cpp

AC · 最終更新 2026-09-06 · GitHub

問題: https://judge.yosupo.jp/problem/point_add_range_sum

依存するヘッダ(2)
実装
// competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/point_add_range_sum
#include <cstdint>
#include <iostream>
#include "data_structure/fenwick_tree.hpp"
#include "template/sonic.hpp"

int main(void) {
    int n, q;
    std::cin >> n >> q;
    std::vector<int> a(n);
    for (auto &e : a) std::cin >> e;
    FenwickTree<std::int64_t> ft(a);
    while (q--) {
        int x, y, z;
        std::cin >> x >> y >> z;
        if (x == 0) ft.add(y, z);
        else std::cout << ft.sum(y, z) << '\n';
    }

    return 0;
}