累積和
(datastructure/cumulative_sum.hpp)
概要
使い方
-
cumulative_sum(d)
: 数列 $\mathrm d$ で初期化する。
-
sum(l, r)
: $\mathrm d_l + \mathrm d_{l+1} + \cdots +\mathrm d_{r-1}$ を求める。
計算量
-
cumulative_sum(d)
: $\mathcal O(N)$
-
sum(l, r)
: $\mathcal O(1)$
Verified with
Code
Back to top page