teacher
Sign in

Segment Tree

Answer range queries and point updates in O(log n) by storing the answer for every halved segment of the array.

45 minCF 1600–23005 interactive9 problems

The problem

You have an array of n numbers and q operations. Each one is either "set a[i] to v" or "print the sum of a[l..r]". Both n and q can reach 200,000.

1 of 10