ll prefix(int rt, int a) {
if (!rt) return 0;
if (a >= n) return tr[rt].sum;
ll res = 0;
int nd = rt;
int l = 1, r = n;
while (nd && l < r) {
int mid = (l + r) >> 1;
if (a <= mid) {
nd = tr[nd].lc;
r = mid;
} else {
res += tr[tr[nd].lc].sum;
nd = tr[nd].rc;
l = mid + 1;
}
}
if (nd) res += tr[nd].sum;
return res;
}111
文章信息与版本
文章信息
- 发布
- 2026年9月11日
- 收录
- 2026年9月11日
- 更新
- 2026年9月11日
- 篇幅
- 约 1 分钟