class

AtCoder::FenwickTree(T)

Inherits Reference / Object

Implements atcoder::fenwick_tree.

tree = AtCoder::FenwickTree(Int64).new(10)
tree.add(3, 10)
tree.add(5, 20)
tree[3..5]  # => 30
tree[3...5] # => 10

Constructors

new(size : Int64)
Source
new(bits : Array)
Source

Instance methods

[](range : Range)

Implements atcoder::fenwick_tree.sum(left, right)

Open ended ranges are clamped at the start and end of array, respectively.

Source
add(index, value)

Implements atcoder::fenwick_tree.add(index, value)

Source
bits
Source
left_sum(index)

Exclusive left sum

Source
size
Source
sum(left, right)

Implements atcoder::fenwick_tree.sum(left, right)

Source
sum(range : Range)

Implements atcoder::fenwick_tree.sum(left, right)

Open ended ranges are clamped at the start and end of array, respectively.

Source