Coding Practice Diary - Recursive C_stalls
f(x, y, k, a, b)
- first input
f(1, 0, k, n, n+1)
1+0 >= k {return b}
k -= x+y
create map<LL,LL>m
and adda--; m[a/2]+=x; m[a-a/2]+=x
// offset of left & right respectivelyvector<pair<LL,LL>> v(m.begin(), m.end())
- return either
a
orb
as t t--
//minus the location of last item it self and then usemax, min
toa/2
anda-a/2
respectively
Core:
m[(n-1)/2] += 1
m[n-1 - (n-1)/2] += 1
n[n/2] += 0
n[n/2] += 0
- Find any longest subsequence of consecutive empty stalls
- Choose the middle stalls
A great explanations by using tree n/2 & (n-1)/2