You need prefix sums with point updates on a large array. Fenwick tree or segment tree? · QuantMax