You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
494 B
18 lines
494 B
#include <iostream> |
|
#include <vector> |
|
|
|
#include "segment_tree.hpp" |
|
|
|
int main() { |
|
std::vector<long long> arr = {1, 3, 5, 7, 9, 11}; |
|
|
|
SumSegmentTree st = make_sum_segment_tree(arr); |
|
|
|
std::cout << "Sum of [1, 3]: " << st.query(1, 3) << '\n'; // 3 + 5 + 7 = 15 |
|
std::cout << "Sum of [0, 5]: " << st.query(0, 5) << '\n'; // 36 |
|
|
|
st.update(2, 10); // arr[2]: 5 -> 10 |
|
std::cout << "Sum of [1, 3] after update: " << st.query(1, 3) << '\n'; // 3 + 10 + 7 = 20 |
|
|
|
return 0; |
|
}
|
|
|