Answers for "binpow in fenwick tree"

0

binpow in fenwick tree

// возвращает индекс, на котором сумма уже больше
int lower_bound (int s) {
    int k = 0;
    for (int l = logn; l >= 0; l--) {
        if (k + (1<<l) <= n && t[k + (1<<l)] < s) {
            k += (1<<l);
            s -= t[k];
        }
    }
    return k;
}
Posted by: Guest on October-19-2021

Browse Popular Code Answers by Language