https://www.sleepingcup.com/solution/P134/68c6be552338344d93c87add

对于上述做法,将树状数组改为主席树,可以在线解决问题。

https://www.luogu.com.cn/problem/P5385