线段树换成树状数组可以有效减少内存占用。
请不要无脑define int long long,至少这道题不需要。尤其是这道题卡内存
树状数组
for(int i=x;i<=MX;i+=lowbit(i))
MX取1000000 WA了,取1000002可以AC,这个我没搞懂,仅供参考。