f(x, y, k, a, b)f(1, 0, k, n, n+1)1+0 >= k {return b}k -= x+ycreate map<LL,LL>m and add a--; m[a/2]+=x; m[a-a/2]+=x // offset of left & right respectivelyvector<pair<LL,LL>> v(m.begin(), m.end())a or b as tt-- //minus the location of last item it self and then use max, min to a/2 and a-a/2 respectivelym[(n-1)/2] += 1
m[n-1 - (n-1)/2] += 1
n[n/2] += 0
n[n/2] += 0
A great explanations by using tree n/2 & (n-1)/2