ContinueLib

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub Continue765/ContinueLib

:heavy_check_mark: test/library_checker/segment_tree_point_add_range_sum.test.cpp

Depends on

Code

#define PROBLEM "https://judge.yosupo.jp/problem/point_add_range_sum"
#include <common.hpp>
#include "algebra/monoid.hpp"
#include "data_structure/segment_tree/segment_tree.hpp"

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, q;
    cin >> n >> q;
    vector<long long> a(n);
    for (auto& x : a) cin >> x;
    SegmentTree<AddMono<long long>> seg(a);
    while (q--) {
        int t, l, r;
        cin >> t >> l >> r;
        if (t == 0) seg.modify(l, seg.query(l, l + 1) + r);
        else cout << seg.query(l, r) << '\n';
    }
}
Back to top page